From 2893632dcedc762e7898d58095fc9c8120f605ef Mon Sep 17 00:00:00 2001 From: CADU110 Date: Thu, 30 Nov 2023 00:29:26 -0300 Subject: [PATCH 1/6] add user model --- gestao/db/models/user.py | 64 +++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 33 deletions(-) diff --git a/gestao/db/models/user.py b/gestao/db/models/user.py index b552353..42381d8 100644 --- a/gestao/db/models/user.py +++ b/gestao/db/models/user.py @@ -1,49 +1,47 @@ from datetime import date, datetime from typing import Optional - -import ormar - from gestao.db.base import BaseMeta - +import ormar class User(ormar.Model): class Meta(BaseMeta): tablename = "user" id: str = ormar.String(max_length=200, primary_key=True) - name: str = ormar.String(max_length=200) + fullName: str = ormar.String(max_length=200) + warName: str = ormar.String(max_length=200, nullable=True) + registration: str = ormar.String(max_length=200, unique=True) + birthDate: date = ormar.Date() + rg: str = ormar.String(max_length=200, unique=True) + cpf: str = ormar.String(max_length=200, unique=True) + placeOfBirth: str = ormar.String(max_length=200) + ufNatural: str = ormar.String(max_length=100) + civilState: str = ormar.String(max_length=200, nullable=True) + cep: str = ormar.String(max_length=100) address: str = ormar.String(max_length=200) - neighborhood: str = ormar.String(max_length=200) + number: str = ormar.String(max_length=100, nullable=True) + neighborhood: str = ormar.String(max_length=100, nullable=True) city: str = ormar.String(max_length=100) - state: str = ormar.String(max_length=100) - zipcode: str = ormar.String(max_length=100) - cpf: str = ormar.String(max_length=200, unique=True) - rg: str = ormar.String(max_length=200, unique=True) - birth_date: date = ormar.Date() - place_of_birth: str = ormar.String(max_length=200) - blood_type: str = ormar.String(max_length=200) - gender: str = ormar.String(max_length=200) - father_name: str = ormar.String(max_length=200) - mother_name: str = ormar.String(max_length=200) - position: str = ormar.String(max_length=200) - occupancy: str = ormar.String(max_length=200) - admission_date: date = ormar.Date() - situation: str = ormar.String(max_length=200) - phone: str = ormar.String(max_length=200) + complement: str = ormar.String(max_length=200, nullable=True) + uf: str = ormar.String(max_length=100) email: str = ormar.String(max_length=200) - marital_status: str = ormar.String(max_length=200) - education: str = ormar.String(max_length=200) - registration: str = ormar.String(max_length=200, unique=True) - role: str = ormar.String(max_length=200) - category: str = ormar.String(max_length=200) - pattern: str = ormar.String(max_length=200) - status: str = ormar.String(max_length=200, default="active") - workstation: Optional[str] = ormar.String(max_length=200, nullable=True) - nickname: Optional[str] = ormar.String(max_length=200, unique=True, nullable=True) + cellphone: str = ormar.String(max_length=200) + phone: str = ormar.String(max_length=200, nullable=True) + gender: str = ormar.String(max_length=200) + motherName: str = ormar.String(max_length=200) + fatherName: str = ormar.String(max_length=200, nullable=True) + scolarity: str = ormar.String(max_length=200, nullable=True) + religion: str = ormar.String(max_length=200, nullable=True) + bloodType: str = ormar.String(max_length=200, nullable=True) + actualWorkSituation: str = ormar.String(max_length=200) + admissionDate: date = ormar.Date() + jobRole: str = ormar.String(max_length=200, nullable=True) + bodyOfLaw: str = ormar.String(max_length=200) + lotation: str = ormar.String(max_length=200, nullable=True) + workPost: str = ormar.String(max_length=200, nullable=True) + systemRole: str = ormar.String(max_length=200, nullable=True) password: str = ormar.String(max_length=200, nullable=True) - religion: Optional[str] = ormar.String(max_length=200, nullable=True) - dispatcher: str = ormar.String(max_length=200) - dispatched_date: date = ormar.Date() + status: str = ormar.String(max_length=200, default="active") created_at: datetime = ormar.DateTime(timezone=True, default=datetime.now) updated_at: datetime = ormar.DateTime( timezone=True, From f00c1089601d8fa4ecaf3f98d41ca157ecaac9cc Mon Sep 17 00:00:00 2001 From: CADU110 Date: Thu, 30 Nov 2023 00:44:58 -0300 Subject: [PATCH 2/6] update --- .../versions/2023-11-30-03-32_dd095623222c.py | 182 ++++++++++++++++++ gestao/web/api/user/schemas.py | 116 ++++++----- 2 files changed, 237 insertions(+), 61 deletions(-) create mode 100644 gestao/db/migrations/versions/2023-11-30-03-32_dd095623222c.py 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 From 0e7208d1da37be953920804203893ba2e238ba19 Mon Sep 17 00:00:00 2001 From: CADU110 Date: Thu, 30 Nov 2023 14:10:05 -0300 Subject: [PATCH 3/6] update migrations --- .../versions/2023-11-29-23-43_d304dbbb6ffe.py | 115 ++++++++++++++++++ user.py | 0 2 files changed, 115 insertions(+) create mode 100644 gestao/db/migrations/versions/2023-11-29-23-43_d304dbbb6ffe.py create mode 100644 user.py diff --git a/gestao/db/migrations/versions/2023-11-29-23-43_d304dbbb6ffe.py b/gestao/db/migrations/versions/2023-11-29-23-43_d304dbbb6ffe.py new file mode 100644 index 0000000..80ad799 --- /dev/null +++ b/gestao/db/migrations/versions/2023-11-29-23-43_d304dbbb6ffe.py @@ -0,0 +1,115 @@ +"""Fix: Refactoring user fields + +Revision ID: d304dbbb6ffe +Revises: 0084e7dffc7c +Create Date: 2023-11-29 23:43:01.708622 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = 'd304dbbb6ffe' +down_revision = '0084e7dffc7c' +branch_labels = None +depends_on = None + + +def upgrade(): + with op.batch_alter_table("user") as batch_op: + batch_op.add_column( + sa.Column("fullName", sa.String(200)), + ) + batch_op.add_column( + sa.Column("warName", sa.String(200), nullable=True), + ) + batch_op.add_column( + sa.Column("birthDate", sa.Date()), + ) + batch_op.add_column( + sa.Column("placeOfBirth", sa.String(200)), + ) + batch_op.add_column( + sa.Column("ufNatural", sa.String(100)), + ) + batch_op.add_column( + sa.Column("civilState", sa.String(100), nullable=True), + ) + batch_op.add_column( + sa.Column("cep", sa.String(100), nullable=True), + ) + batch_op.add_column( + sa.Column("number", sa.String(100), nullable=True), + ) + batch_op.add_column( + sa.Column("complement", sa.String(200), nullable=True), + ) + batch_op.add_column( + sa.Column("uf", sa.String(100)), + ) + batch_op.add_column( + sa.Column("cellphone", sa.String(200)), + ) + batch_op.add_column( + sa.Column("motherName", sa.String(200)), + ) + batch_op.add_column( + sa.Column("fatherName", sa.String(200), nullable=True), + ) + batch_op.add_column( + sa.Column("scolarity", sa.String(200), nullable=True), + ) + batch_op.add_column( + sa.Column("bloodType", sa.String(200), nullable=True), + ) + batch_op.add_column( + sa.Column("actualWorkSituation", sa.String(200)), + ) + batch_op.add_column( + sa.Column("admissionDate", sa.Date()), + ) + batch_op.add_column( + sa.Column("jobRole", sa.String(200), nullable=True), + ) + batch_op.add_column( + sa.Column("bodyOfLaw", sa.String(200)), + ) + batch_op.add_column( + sa.Column("lotation", sa.String(200), nullable=True), + ) + batch_op.add_column( + sa.Column("workPost", sa.String(200), nullable=True), + ) + batch_op.add_column( + sa.Column("systemRole", sa.String(200), nullable=True), + ) + batch_op.add_column( + sa.Column("password", sa.String(200), nullable=True), + ) + + +def downgrade(): + with op.batch_alter_table("user") as batch_op: + batch_op.drop_column("name") + batch_op.drop_column("nickname") + batch_op.drop_column("birth_date") + batch_op.drop_column("place_of_birth") + batch_op.drop_column("marital_status") + batch_op.drop_column("zipcode") + batch_op.drop_column("state") + batch_op.drop_column("mother_date") + batch_op.drop_column("mother_name") + batch_op.drop_column("father_name") + batch_op.drop_column("education") + batch_op.drop_column("blood_type") + batch_op.drop_column("situation") + batch_op.drop_column("role") + batch_op.drop_column("workstation") + batch_op.drop_column("dispatcher") + batch_op.drop_column("dispatched_date") + batch_op.drop_column("position") + batch_op.drop_column("occupancy") + batch_op.drop_column("admission_date") + batch_op.drop_column("category") + batch_op.drop_column("pattern") \ No newline at end of file diff --git a/user.py b/user.py new file mode 100644 index 0000000..e69de29 From 5ae15ba66e2e80aab5529800a596f11bb9b26843 Mon Sep 17 00:00:00 2001 From: Eduard0803 Date: Fri, 1 Dec 2023 19:34:03 -0300 Subject: [PATCH 4/6] fix: migrations and schemas-user Co-Authored-by: Carlos Eduardo --- .../versions/2023-11-29-23-43_d304dbbb6ffe.py | 115 ----------- .../versions/2023-11-30-03-32_dd095623222c.py | 182 ------------------ .../versions/2023-12-01-21-33_02379f0ee4ac.py | 159 +++++++++++++++ gestao/web/api/user/schemas.py | 10 +- gestao/web/api/user/views.py | 2 +- 5 files changed, 167 insertions(+), 301 deletions(-) delete mode 100644 gestao/db/migrations/versions/2023-11-29-23-43_d304dbbb6ffe.py delete mode 100644 gestao/db/migrations/versions/2023-11-30-03-32_dd095623222c.py create mode 100644 gestao/db/migrations/versions/2023-12-01-21-33_02379f0ee4ac.py diff --git a/gestao/db/migrations/versions/2023-11-29-23-43_d304dbbb6ffe.py b/gestao/db/migrations/versions/2023-11-29-23-43_d304dbbb6ffe.py deleted file mode 100644 index 80ad799..0000000 --- a/gestao/db/migrations/versions/2023-11-29-23-43_d304dbbb6ffe.py +++ /dev/null @@ -1,115 +0,0 @@ -"""Fix: Refactoring user fields - -Revision ID: d304dbbb6ffe -Revises: 0084e7dffc7c -Create Date: 2023-11-29 23:43:01.708622 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = 'd304dbbb6ffe' -down_revision = '0084e7dffc7c' -branch_labels = None -depends_on = None - - -def upgrade(): - with op.batch_alter_table("user") as batch_op: - batch_op.add_column( - sa.Column("fullName", sa.String(200)), - ) - batch_op.add_column( - sa.Column("warName", sa.String(200), nullable=True), - ) - batch_op.add_column( - sa.Column("birthDate", sa.Date()), - ) - batch_op.add_column( - sa.Column("placeOfBirth", sa.String(200)), - ) - batch_op.add_column( - sa.Column("ufNatural", sa.String(100)), - ) - batch_op.add_column( - sa.Column("civilState", sa.String(100), nullable=True), - ) - batch_op.add_column( - sa.Column("cep", sa.String(100), nullable=True), - ) - batch_op.add_column( - sa.Column("number", sa.String(100), nullable=True), - ) - batch_op.add_column( - sa.Column("complement", sa.String(200), nullable=True), - ) - batch_op.add_column( - sa.Column("uf", sa.String(100)), - ) - batch_op.add_column( - sa.Column("cellphone", sa.String(200)), - ) - batch_op.add_column( - sa.Column("motherName", sa.String(200)), - ) - batch_op.add_column( - sa.Column("fatherName", sa.String(200), nullable=True), - ) - batch_op.add_column( - sa.Column("scolarity", sa.String(200), nullable=True), - ) - batch_op.add_column( - sa.Column("bloodType", sa.String(200), nullable=True), - ) - batch_op.add_column( - sa.Column("actualWorkSituation", sa.String(200)), - ) - batch_op.add_column( - sa.Column("admissionDate", sa.Date()), - ) - batch_op.add_column( - sa.Column("jobRole", sa.String(200), nullable=True), - ) - batch_op.add_column( - sa.Column("bodyOfLaw", sa.String(200)), - ) - batch_op.add_column( - sa.Column("lotation", sa.String(200), nullable=True), - ) - batch_op.add_column( - sa.Column("workPost", sa.String(200), nullable=True), - ) - batch_op.add_column( - sa.Column("systemRole", sa.String(200), nullable=True), - ) - batch_op.add_column( - sa.Column("password", sa.String(200), nullable=True), - ) - - -def downgrade(): - with op.batch_alter_table("user") as batch_op: - batch_op.drop_column("name") - batch_op.drop_column("nickname") - batch_op.drop_column("birth_date") - batch_op.drop_column("place_of_birth") - batch_op.drop_column("marital_status") - batch_op.drop_column("zipcode") - batch_op.drop_column("state") - batch_op.drop_column("mother_date") - batch_op.drop_column("mother_name") - batch_op.drop_column("father_name") - batch_op.drop_column("education") - batch_op.drop_column("blood_type") - batch_op.drop_column("situation") - batch_op.drop_column("role") - batch_op.drop_column("workstation") - batch_op.drop_column("dispatcher") - batch_op.drop_column("dispatched_date") - batch_op.drop_column("position") - batch_op.drop_column("occupancy") - batch_op.drop_column("admission_date") - batch_op.drop_column("category") - batch_op.drop_column("pattern") \ No newline at end of file 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 deleted file mode 100644 index 4b1b9ef..0000000 --- a/gestao/db/migrations/versions/2023-11-30-03-32_dd095623222c.py +++ /dev/null @@ -1,182 +0,0 @@ -"""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/db/migrations/versions/2023-12-01-21-33_02379f0ee4ac.py b/gestao/db/migrations/versions/2023-12-01-21-33_02379f0ee4ac.py new file mode 100644 index 0000000..ce75b0c --- /dev/null +++ b/gestao/db/migrations/versions/2023-12-01-21-33_02379f0ee4ac.py @@ -0,0 +1,159 @@ +"""Fix: Refactoring user fields + +Revision ID: 02379f0ee4ac +Revises: 89f33fa986f8 +Create Date: 2023-12-01 21:33:24.578159 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '02379f0ee4ac' +down_revision = '89f33fa986f8' +branch_labels = None +depends_on = None + + +def upgrade() -> None: + op.drop_table('dependent') + op.drop_table('user') + + op.create_table( + "user", + sa.Column("id", sa.String(length=200), primary_key=True, nullable=False), + sa.Column("fullName", sa.String(length=200), nullable=False), + sa.Column("warName", sa.String(length=200), nullable=True), + sa.Column("registration", sa.String(length=200), unique=True, nullable=False), + sa.Column("birthDate", sa.Date(), nullable=False), + sa.Column("rg", sa.String(length=200), unique=True, nullable=False), + sa.Column("cpf", sa.String(length=200), unique=True, nullable=False), + sa.Column("placeOfBirth", sa.String(length=200), nullable=False), + sa.Column("ufNatural", sa.String(length=200), nullable=False), + sa.Column("civilState", sa.String(length=200), nullable=False), + sa.Column("cep", sa.String(length=200), nullable=False), + sa.Column("address", sa.String(length=200), nullable=False), + sa.Column("number", sa.String(length=200), nullable=False), + sa.Column("neighborhood", sa.String(length=200), nullable=False), + sa.Column("city", sa.String(length=200), nullable=False), + sa.Column("complement", sa.String(length=200), nullable=False), + sa.Column("uf", sa.String(length=200), nullable=False), + sa.Column("email", sa.String(length=200), unique=True, nullable=False), + sa.Column("cellphone", sa.String(length=200), nullable=False), + sa.Column("phone", sa.String(length=200), nullable=False), + sa.Column("gender", sa.String(length=200), nullable=False), + sa.Column("motherName", sa.String(length=200), nullable=False), + sa.Column("fatherName", sa.String(length=200), nullable=False), + sa.Column("scolarity", sa.String(length=200), nullable=False), + sa.Column("religion", sa.String(length=200), nullable=False), + sa.Column("bloodType", sa.String(length=200), nullable=False), + sa.Column("actualWorkSituation", sa.String(length=200), nullable=False), + sa.Column("admissionDate", sa.Date(), nullable=False), + sa.Column("jobRole", sa.String(length=200), nullable=False), + sa.Column("bodyOfLaw", sa.String(length=200), nullable=False), + sa.Column("lotation", sa.String(length=200), nullable=False), + sa.Column("workPost", sa.String(length=200), nullable=False), + sa.Column("systemRole", sa.String(length=200), nullable=False), + sa.Column("password", sa.String(length=200), nullable=False), + sa.Column("status", sa.String(length=200), nullable=False), + sa.Column( + "created_at", + sa.DateTime(timezone=True), + server_default=sa.func.now(), + nullable=False, + ), + sa.Column( + "updated_at", + sa.DateTime(timezone=True), + server_default=sa.func.now(), + nullable=False, + ), + schema="public", + ) + + op.create_table( + "dependent", + sa.Column("id", sa.String(length=200), primary_key=True, nullable=False), + sa.Column( + "user_id", + sa.String(length=200), + sa.ForeignKey("user.id", ondelete="CASCADE"), + nullable=False, + ), + sa.Column("name", sa.String(length=200), nullable=False), + sa.Column("birth_date", sa.Date(), nullable=False), + sa.Column("relationship", sa.String(length=200), nullable=False), + sa.Column("cpf", sa.String(200), nullable=True, unique=True), + sa.Column("gender", sa.String(200), nullable=True), + sa.Column("phone", sa.String(200), nullable=True), + sa.Column("pensioner", sa.Boolean(), default=False), + sa.Column( + "created_at", + sa.DateTime(timezone=True), + server_default=sa.func.now(), + nullable=False, + ), + sa.Column( + "updated_at", + sa.DateTime(timezone=True), + server_default=sa.func.now(), + nullable=False, + ), + schema="public", + ) + + +def downgrade() -> None: + op.drop_table('dependent') + op.drop_table('user') + + op.create_table( + "user", + sa.Column("id", sa.String(length=200), primary_key=True, nullable=False), + sa.Column("name", sa.String(length=200), nullable=False), + sa.Column("address", sa.String(length=200), nullable=True), + sa.Column("neighborhood", sa.String(length=200), nullable=False), + sa.Column("city", sa.String(length=200), nullable=False), + sa.Column("state", sa.String(length=200), nullable=False), + sa.Column("zipcode", sa.String(length=200), nullable=False), + sa.Column("cpf", sa.String(length=200), unique=True, nullable=False), + sa.Column("rg", sa.String(length=200), unique=True, nullable=False), + sa.Column("birth_date", sa.Date(), nullable=False), + sa.Column("place_of_birth", sa.String(length=200), nullable=False), + sa.Column("blood_type", sa.String(length=200), nullable=False), + sa.Column("gender", sa.String(length=200), nullable=False), + sa.Column("father_name", sa.String(length=200), nullable=False), + sa.Column("mother_name", sa.String(length=200), nullable=False), + sa.Column("position", sa.String(length=200), nullable=False), + sa.Column("admission_date", sa.Date(), nullable=False), + sa.Column("situation", sa.String(length=200), nullable=False), + sa.Column("phone", sa.String(length=200), nullable=False), + sa.Column("email", sa.String(length=200), unique=True, nullable=False), + sa.Column("marital_status", sa.String(length=200), nullable=False), + sa.Column("education", sa.String(length=200), nullable=False), + sa.Column("registration", sa.String(length=200), unique=True, nullable=False), + sa.Column("role", sa.String(length=200), nullable=False), + sa.Column("category", sa.String(length=200), nullable=False), + sa.Column("pattern", sa.String(length=200), nullable=False), + sa.Column("status", sa.String(length=200), nullable=False), + sa.Column("workstation", sa.String(length=200), nullable=False), + sa.Column("nickname", sa.String(length=200), nullable=False), + sa.Column("password", sa.String(length=200), nullable=False), + sa.Column("religion", sa.String(length=200), nullable=False), + sa.Column("dispatcher", sa.String(length=200), nullable=False), + sa.Column("dispatched_date", sa.Date(), nullable=False), + sa.Column( + "created_at", + sa.DateTime(timezone=True), + server_default=sa.func.now(), + nullable=False, + ), + sa.Column( + "updated_at", + sa.DateTime(timezone=True), + server_default=sa.func.now(), + nullable=False, + ), + schema="public", + ) diff --git a/gestao/web/api/user/schemas.py b/gestao/web/api/user/schemas.py index 4925c92..76c479b 100644 --- a/gestao/web/api/user/schemas.py +++ b/gestao/web/api/user/schemas.py @@ -25,6 +25,7 @@ class CreateUserDTO(BaseModel): cep: str address: str number: Optional[str] + neighborhood: str city: str uf: str complement: Optional[str] @@ -37,14 +38,15 @@ class CreateUserDTO(BaseModel): 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] + jobRole: str dependents: Optional[List[CreateUserDependentDTO]] + password: str class UpdateUserDTO(BaseModel): fullName: Optional[str] @@ -59,6 +61,7 @@ class UpdateUserDTO(BaseModel): cep: Optional[str] address: Optional[str] number: Optional[str] + neighborhood: Optional[str] city: Optional[str] uf: Optional[str] complement: Optional[str] @@ -71,10 +74,11 @@ class UpdateUserDTO(BaseModel): 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 + jobRole: Optional[str] + systemRole: Optional[str] + password: Optional[str] diff --git a/gestao/web/api/user/views.py b/gestao/web/api/user/views.py index a04f36a..d26d746 100644 --- a/gestao/web/api/user/views.py +++ b/gestao/web/api/user/views.py @@ -23,7 +23,7 @@ async def get_users( .offset( offset, ) - .filter(status=UserStatus.active) + # .filter(status=UserStatus.active) .all() ) From f0fab18a5072fd626545cf148896a6d40465ed98 Mon Sep 17 00:00:00 2001 From: Eduard0803 Date: Fri, 1 Dec 2023 19:35:18 -0300 Subject: [PATCH 5/6] reformat files --- .../versions/2023-12-01-21-33_02379f0ee4ac.py | 16 ++++++++-------- gestao/db/models/user.py | 1 + gestao/web/api/user/schemas.py | 3 +++ gestao/web/api/user/views.py | 3 +-- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/gestao/db/migrations/versions/2023-12-01-21-33_02379f0ee4ac.py b/gestao/db/migrations/versions/2023-12-01-21-33_02379f0ee4ac.py index ce75b0c..52bd652 100644 --- a/gestao/db/migrations/versions/2023-12-01-21-33_02379f0ee4ac.py +++ b/gestao/db/migrations/versions/2023-12-01-21-33_02379f0ee4ac.py @@ -10,16 +10,16 @@ # revision identifiers, used by Alembic. -revision = '02379f0ee4ac' -down_revision = '89f33fa986f8' +revision = "02379f0ee4ac" +down_revision = "89f33fa986f8" branch_labels = None depends_on = None def upgrade() -> None: - op.drop_table('dependent') - op.drop_table('user') - + op.drop_table("dependent") + op.drop_table("user") + op.create_table( "user", sa.Column("id", sa.String(length=200), primary_key=True, nullable=False), @@ -105,9 +105,9 @@ def upgrade() -> None: def downgrade() -> None: - op.drop_table('dependent') - op.drop_table('user') - + op.drop_table("dependent") + op.drop_table("user") + op.create_table( "user", sa.Column("id", sa.String(length=200), primary_key=True, nullable=False), diff --git a/gestao/db/models/user.py b/gestao/db/models/user.py index 42381d8..4f59276 100644 --- a/gestao/db/models/user.py +++ b/gestao/db/models/user.py @@ -3,6 +3,7 @@ from gestao.db.base import BaseMeta import ormar + class User(ormar.Model): class Meta(BaseMeta): tablename = "user" diff --git a/gestao/web/api/user/schemas.py b/gestao/web/api/user/schemas.py index 76c479b..2bceefb 100644 --- a/gestao/web/api/user/schemas.py +++ b/gestao/web/api/user/schemas.py @@ -3,6 +3,7 @@ from pydantic import BaseModel + class CreateUserDependentDTO(BaseModel): name: str birth_date: date @@ -12,6 +13,7 @@ class CreateUserDependentDTO(BaseModel): phone: str pensioner: Optional[str] + class CreateUserDTO(BaseModel): fullName: str warName: Optional[str] @@ -48,6 +50,7 @@ class CreateUserDTO(BaseModel): dependents: Optional[List[CreateUserDependentDTO]] password: str + class UpdateUserDTO(BaseModel): fullName: Optional[str] warName: Optional[str] diff --git a/gestao/web/api/user/views.py b/gestao/web/api/user/views.py index d26d746..9630fc9 100644 --- a/gestao/web/api/user/views.py +++ b/gestao/web/api/user/views.py @@ -19,8 +19,7 @@ async def get_users( offset: int = 0, ) -> List[User]: return ( - await User.objects.limit(limit) - .offset( + await User.objects.limit(limit).offset( offset, ) # .filter(status=UserStatus.active) From e5a5b2637bcfb0a4b3785a62b2b9f5dea438de97 Mon Sep 17 00:00:00 2001 From: Eduard0803 Date: Sat, 2 Dec 2023 12:15:43 -0300 Subject: [PATCH 6/6] fix: update migrations and user-schemas --- .../versions/2023-12-01-21-33_02379f0ee4ac.py | 31 +++++++++++++++++++ gestao/web/api/user/schemas.py | 6 ++-- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/gestao/db/migrations/versions/2023-12-01-21-33_02379f0ee4ac.py b/gestao/db/migrations/versions/2023-12-01-21-33_02379f0ee4ac.py index 52bd652..71b3340 100644 --- a/gestao/db/migrations/versions/2023-12-01-21-33_02379f0ee4ac.py +++ b/gestao/db/migrations/versions/2023-12-01-21-33_02379f0ee4ac.py @@ -157,3 +157,34 @@ def downgrade() -> None: ), schema="public", ) + + op.create_table( + "dependent", + sa.Column("id", sa.String(length=200), primary_key=True, nullable=False), + sa.Column( + "user_id", + sa.String(length=200), + sa.ForeignKey("user.id", ondelete="CASCADE"), + nullable=False, + ), + sa.Column("name", sa.String(length=200), nullable=False), + sa.Column("birth_date", sa.Date(), nullable=False), + sa.Column("relationship", sa.String(length=200), nullable=False), + sa.Column("cpf", sa.String(200), nullable=True, unique=True), + sa.Column("gender", sa.String(200), nullable=True), + sa.Column("phone", sa.String(200), nullable=True), + sa.Column("pensioner", sa.Boolean(), default=False), + sa.Column( + "created_at", + sa.DateTime(timezone=True), + server_default=sa.func.now(), + nullable=False, + ), + sa.Column( + "updated_at", + sa.DateTime(timezone=True), + server_default=sa.func.now(), + nullable=False, + ), + schema="public", + ) diff --git a/gestao/web/api/user/schemas.py b/gestao/web/api/user/schemas.py index 2bceefb..35ca7a3 100644 --- a/gestao/web/api/user/schemas.py +++ b/gestao/web/api/user/schemas.py @@ -29,8 +29,8 @@ class CreateUserDTO(BaseModel): number: Optional[str] neighborhood: str city: str - uf: str complement: Optional[str] + uf: str email: str cellphone: str phone: Optional[str] @@ -42,13 +42,13 @@ class CreateUserDTO(BaseModel): bloodType: Optional[str] actualWorkSituation: str admissionDate: date + jobRole: str bodyOfLaw: str lotation: Optional[str] workPost: Optional[str] systemRole: Optional[str] - jobRole: str dependents: Optional[List[CreateUserDependentDTO]] - password: str + password: Optional[str] class UpdateUserDTO(BaseModel):