diff --git a/gestao/db/migrations/versions/2023-11-30-03-32_dd095623222c.py b/gestao/db/migrations/versions/2023-11-30-03-32_dd095623222c.py new file mode 100644 index 0000000..4b1b9ef --- /dev/null +++ b/gestao/db/migrations/versions/2023-11-30-03-32_dd095623222c.py @@ -0,0 +1,182 @@ +"""empty message + +Revision ID: dd095623222c +Revises: 89f33fa986f8 +Create Date: 2023-11-30 03:32:28.929786 + +""" +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import postgresql + +# revision identifiers, used by Alembic. +revision = 'dd095623222c' +down_revision = '89f33fa986f8' +branch_labels = None +depends_on = None + + +def upgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.alter_column('dependent', 'user_id', + existing_type=sa.VARCHAR(length=200), + nullable=True) + op.alter_column('dependent', 'cpf', + existing_type=sa.VARCHAR(length=200), + nullable=False) + op.alter_column('dependent', 'gender', + existing_type=sa.VARCHAR(length=200), + nullable=False) + op.alter_column('dependent', 'phone', + existing_type=sa.VARCHAR(length=200), + nullable=False) + op.alter_column('dependent', 'created_at', + existing_type=postgresql.TIMESTAMP(timezone=True), + nullable=True, + existing_server_default=sa.text('now()')) + op.alter_column('dependent', 'updated_at', + existing_type=postgresql.TIMESTAMP(timezone=True), + nullable=True, + existing_server_default=sa.text('now()')) + op.add_column('user', sa.Column('fullName', sa.String(length=200), nullable=False)) + op.add_column('user', sa.Column('warName', sa.String(length=200), nullable=True)) + op.add_column('user', sa.Column('birthDate', sa.Date(), nullable=False)) + op.add_column('user', sa.Column('placeOfBirth', sa.String(length=200), nullable=False)) + op.add_column('user', sa.Column('ufNatural', sa.String(length=100), nullable=False)) + op.add_column('user', sa.Column('civilState', sa.String(length=200), nullable=True)) + op.add_column('user', sa.Column('cep', sa.String(length=100), nullable=False)) + op.add_column('user', sa.Column('number', sa.String(length=100), nullable=True)) + op.add_column('user', sa.Column('complement', sa.String(length=200), nullable=True)) + op.add_column('user', sa.Column('uf', sa.String(length=100), nullable=False)) + op.add_column('user', sa.Column('cellphone', sa.String(length=200), nullable=False)) + op.add_column('user', sa.Column('motherName', sa.String(length=200), nullable=False)) + op.add_column('user', sa.Column('fatherName', sa.String(length=200), nullable=True)) + op.add_column('user', sa.Column('scolarity', sa.String(length=200), nullable=True)) + op.add_column('user', sa.Column('bloodType', sa.String(length=200), nullable=True)) + op.add_column('user', sa.Column('actualWorkSituation', sa.String(length=200), nullable=False)) + op.add_column('user', sa.Column('admissionDate', sa.Date(), nullable=False)) + op.add_column('user', sa.Column('jobRole', sa.String(length=200), nullable=True)) + op.add_column('user', sa.Column('bodyOfLaw', sa.String(length=200), nullable=False)) + op.add_column('user', sa.Column('lotation', sa.String(length=200), nullable=True)) + op.add_column('user', sa.Column('workPost', sa.String(length=200), nullable=True)) + op.add_column('user', sa.Column('systemRole', sa.String(length=200), nullable=True)) + op.alter_column('user', 'neighborhood', + existing_type=sa.VARCHAR(length=200), + type_=sa.String(length=100), + nullable=True) + op.alter_column('user', 'phone', + existing_type=sa.VARCHAR(length=200), + nullable=True) + op.alter_column('user', 'created_at', + existing_type=postgresql.TIMESTAMP(timezone=True), + nullable=True, + existing_server_default=sa.text('now()')) + op.alter_column('user', 'updated_at', + existing_type=postgresql.TIMESTAMP(timezone=True), + nullable=True, + existing_server_default=sa.text('now()')) + op.drop_column('user', 'dispatched_date') + op.drop_column('user', 'marital_status') + op.drop_column('user', 'state') + op.drop_column('user', 'name') + op.drop_column('user', 'blood_type') + op.drop_column('user', 'father_name') + op.drop_column('user', 'category') + op.drop_column('user', 'mother_name') + op.drop_column('user', 'pattern') + op.drop_column('user', 'position') + op.drop_column('user', 'zipcode') + op.drop_column('user', 'place_of_birth') + op.drop_column('user', 'role') + op.drop_column('user', 'dispatcher') + op.drop_column('user', 'education') + op.drop_column('user', 'birth_date') + op.drop_column('user', 'situation') + op.drop_column('user', 'occupancy') + op.drop_column('user', 'admission_date') + op.drop_column('user', 'workstation') + op.drop_column('user', 'nickname') + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.add_column('user', sa.Column('nickname', sa.VARCHAR(length=200), autoincrement=False, nullable=True)) + op.add_column('user', sa.Column('workstation', sa.VARCHAR(length=200), autoincrement=False, nullable=True)) + op.add_column('user', sa.Column('admission_date', sa.DATE(), autoincrement=False, nullable=False)) + op.add_column('user', sa.Column('occupancy', sa.VARCHAR(length=200), autoincrement=False, nullable=False)) + op.add_column('user', sa.Column('situation', sa.VARCHAR(length=200), autoincrement=False, nullable=False)) + op.add_column('user', sa.Column('birth_date', sa.DATE(), autoincrement=False, nullable=False)) + op.add_column('user', sa.Column('education', sa.VARCHAR(length=200), autoincrement=False, nullable=False)) + op.add_column('user', sa.Column('dispatcher', sa.VARCHAR(length=200), autoincrement=False, nullable=False)) + op.add_column('user', sa.Column('role', sa.VARCHAR(length=200), autoincrement=False, nullable=False)) + op.add_column('user', sa.Column('place_of_birth', sa.VARCHAR(length=200), autoincrement=False, nullable=False)) + op.add_column('user', sa.Column('zipcode', sa.VARCHAR(length=100), autoincrement=False, nullable=False)) + op.add_column('user', sa.Column('position', sa.VARCHAR(length=200), autoincrement=False, nullable=False)) + op.add_column('user', sa.Column('pattern', sa.VARCHAR(length=200), autoincrement=False, nullable=False)) + op.add_column('user', sa.Column('mother_name', sa.VARCHAR(length=200), autoincrement=False, nullable=False)) + op.add_column('user', sa.Column('category', sa.VARCHAR(length=200), autoincrement=False, nullable=False)) + op.add_column('user', sa.Column('father_name', sa.VARCHAR(length=200), autoincrement=False, nullable=False)) + op.add_column('user', sa.Column('blood_type', sa.VARCHAR(length=200), autoincrement=False, nullable=False)) + op.add_column('user', sa.Column('name', sa.VARCHAR(length=200), autoincrement=False, nullable=False)) + op.add_column('user', sa.Column('state', sa.VARCHAR(length=100), autoincrement=False, nullable=False)) + op.add_column('user', sa.Column('marital_status', sa.VARCHAR(length=200), autoincrement=False, nullable=False)) + op.add_column('user', sa.Column('dispatched_date', sa.DATE(), autoincrement=False, nullable=False)) + op.alter_column('user', 'updated_at', + existing_type=postgresql.TIMESTAMP(timezone=True), + nullable=False, + existing_server_default=sa.text('now()')) + op.alter_column('user', 'created_at', + existing_type=postgresql.TIMESTAMP(timezone=True), + nullable=False, + existing_server_default=sa.text('now()')) + op.alter_column('user', 'phone', + existing_type=sa.VARCHAR(length=200), + nullable=False) + op.alter_column('user', 'neighborhood', + existing_type=sa.String(length=100), + type_=sa.VARCHAR(length=200), + nullable=False) + op.drop_column('user', 'systemRole') + op.drop_column('user', 'workPost') + op.drop_column('user', 'lotation') + op.drop_column('user', 'bodyOfLaw') + op.drop_column('user', 'jobRole') + op.drop_column('user', 'admissionDate') + op.drop_column('user', 'actualWorkSituation') + op.drop_column('user', 'bloodType') + op.drop_column('user', 'scolarity') + op.drop_column('user', 'fatherName') + op.drop_column('user', 'motherName') + op.drop_column('user', 'cellphone') + op.drop_column('user', 'uf') + op.drop_column('user', 'complement') + op.drop_column('user', 'number') + op.drop_column('user', 'cep') + op.drop_column('user', 'civilState') + op.drop_column('user', 'ufNatural') + op.drop_column('user', 'placeOfBirth') + op.drop_column('user', 'birthDate') + op.drop_column('user', 'warName') + op.drop_column('user', 'fullName') + op.alter_column('dependent', 'updated_at', + existing_type=postgresql.TIMESTAMP(timezone=True), + nullable=False, + existing_server_default=sa.text('now()')) + op.alter_column('dependent', 'created_at', + existing_type=postgresql.TIMESTAMP(timezone=True), + nullable=False, + existing_server_default=sa.text('now()')) + op.alter_column('dependent', 'phone', + existing_type=sa.VARCHAR(length=200), + nullable=True) + op.alter_column('dependent', 'gender', + existing_type=sa.VARCHAR(length=200), + nullable=True) + op.alter_column('dependent', 'cpf', + existing_type=sa.VARCHAR(length=200), + nullable=True) + op.alter_column('dependent', 'user_id', + existing_type=sa.VARCHAR(length=200), + nullable=False) + # ### end Alembic commands ### diff --git a/gestao/web/api/user/schemas.py b/gestao/web/api/user/schemas.py index 2d0599c..4925c92 100644 --- a/gestao/web/api/user/schemas.py +++ b/gestao/web/api/user/schemas.py @@ -3,7 +3,6 @@ from pydantic import BaseModel - class CreateUserDependentDTO(BaseModel): name: str birth_date: date @@ -13,74 +12,69 @@ class CreateUserDependentDTO(BaseModel): phone: str pensioner: Optional[str] - class CreateUserDTO(BaseModel): - name: str + fullName: str + warName: Optional[str] + registration: str + birthDate: date + rg: str + cpf: str + placeOfBirth: str + ufNatural: str + civilState: Optional[str] + cep: str address: str - neighborhood: str + number: Optional[str] city: str - state: str - zipcode: str - cpf: str - rg: str - birth_date: date - place_of_birth: str - blood_type: str - gender: str - father_name: str - mother_name: str - position: str - occupancy: str - admission_date: date - situation: str - phone: str + uf: str + complement: Optional[str] email: str - marital_status: str - education: str - registration: str - role: str - category: str - pattern: str - dispatcher: str - dispatched_date: date - dependents: Optional[List[CreateUserDependentDTO]] - workstation: Optional[str] - nickname: Optional[str] - password: str + cellphone: str + phone: Optional[str] + gender: str + motherName: str + fatherName: Optional[str] + scolarity: Optional[str] religion: Optional[str] - + bloodType: Optional[str] + function: str + actualWorkSituation: str + admissionDate: date + bodyOfLaw: str + lotation: Optional[str] + workPost: Optional[str] + systemRole: Optional[str] + dependents: Optional[List[CreateUserDependentDTO]] class UpdateUserDTO(BaseModel): - name: Optional[str] + fullName: Optional[str] + warName: Optional[str] + registration: Optional[str] + birthDate: Optional[date] + rg: Optional[str] + cpf: Optional[str] + placeOfBirth: Optional[str] + ufNatural: Optional[str] + civilState: Optional[str] + cep: Optional[str] address: Optional[str] - neighborhood: Optional[str] + number: Optional[str] city: Optional[str] - state: Optional[str] - zipcode: Optional[str] - cpf: Optional[str] - rg: Optional[str] - birth_date: Optional[date] - place_of_birth: Optional[str] - blood_type: Optional[str] - gender: Optional[str] - father_name: Optional[str] - mother_name: Optional[str] - position: Optional[str] - occupancy: Optional[str] - admission_date: Optional[date] - situation: Optional[str] - phone: Optional[str] + uf: Optional[str] + complement: Optional[str] email: Optional[str] - marital_status: Optional[str] - education: Optional[str] - registration: Optional[str] - role: Optional[str] - category: Optional[str] - pattern: Optional[str] - dispatcher: Optional[str] - dispatched_date: Optional[date] - workstation: Optional[str] - nickname: Optional[str] - status: Optional[str] - password: Optional[str] + cellphone: Optional[str] + phone: Optional[str] + gender: Optional[str] + motherName: Optional[str] + fatherName: Optional[str] + scolarity: Optional[str] religion: Optional[str] + bloodType: Optional[str] + function: Optional[str] + actualWorkSituation: Optional[str] + admissionDate: Optional[date] + bodyOfLaw: Optional[str] + lotation: Optional[str] + workPost: Optional[str] + systemRole: Optional[str] \ No newline at end of file