-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from fga-eps-mds/feat/dependents
feat: add dependents rules
- Loading branch information
Showing
5 changed files
with
104 additions
and
14 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
gestao/db/migrations/versions/2023-10-22-02-46_532e4deb3c37.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
"""dependent table | ||
Revision ID: 532e4deb3c37 | ||
Revises: 071cefd86342 | ||
Create Date: 2023-10-22 02:46:30.124158 | ||
""" | ||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "532e4deb3c37" | ||
down_revision = "071cefd86342" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade() -> None: | ||
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( | ||
"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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from datetime import date, datetime | ||
|
||
import ormar | ||
|
||
from gestao.db.base import BaseMeta | ||
from gestao.db.models.user import User | ||
|
||
|
||
class Dependent(ormar.Model): | ||
class Meta(BaseMeta): | ||
tablename = "dependent" | ||
|
||
id: str = ormar.String(max_length=200, primary_key=True) | ||
user_id: User = ormar.ForeignKey(User, ondelete=ormar.ReferentialAction.CASCADE) | ||
name: str = ormar.String(max_length=200) | ||
birth_date: date = ormar.Date() | ||
relationship: str = ormar.String(max_length=200) | ||
created_at: datetime = ormar.DateTime(timezone=True, default=datetime.now) | ||
updated_at: datetime = ormar.DateTime( | ||
timezone=True, | ||
default=datetime.now, | ||
onupdate=datetime.now, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters