версия ленивого Кирилла

This commit is contained in:
dderbentsov
2023-07-18 01:27:43 +03:00
parent 322f14c096
commit 4b10f70db0
10 changed files with 269 additions and 70 deletions

View File

@@ -1,33 +0,0 @@
"""initial
Revision ID: 16041bfd2411
Revises:
Create Date: 2023-07-13 01:26:56.342068
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '16041bfd2411'
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('people',
sa.Column('id', sa.UUID(), nullable=False),
sa.Column('first_name', sa.Text(), nullable=False),
sa.Column('last_name', sa.Text(), nullable=False),
sa.PrimaryKeyConstraint('id')
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('people')
# ### end Alembic commands ###

View File

@@ -0,0 +1,32 @@
"""fix FK
Revision ID: 3510de1e1ff1
Revises: 58cc3bbaabd1
Create Date: 2023-07-16 01:28:47.704514
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '3510de1e1ff1'
down_revision = '58cc3bbaabd1'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_foreign_key(None, 'addresses', 'persons', ['person_id'], ['id'])
op.create_foreign_key(None, 'contacts', 'persons', ['person_id'], ['id'])
op.create_foreign_key(None, 'documents', 'persons', ['person_id'], ['id'])
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(None, 'documents', type_='foreignkey')
op.drop_constraint(None, 'contacts', type_='foreignkey')
op.drop_constraint(None, 'addresses', type_='foreignkey')
# ### end Alembic commands ###

View File

@@ -0,0 +1,85 @@
"""person, address, contact, document v1
Revision ID: 58cc3bbaabd1
Revises: c74556e04b57
Create Date: 2023-07-16 01:19:02.307879
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision = '58cc3bbaabd1'
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('addresses',
sa.Column('category', sa.String(length=30), nullable=False),
sa.Column('region', sa.String(length=100), nullable=True),
sa.Column('city', sa.String(length=100), nullable=True),
sa.Column('street', sa.String(length=100), nullable=True),
sa.Column('house', sa.String(length=100), nullable=True),
sa.Column('flat', sa.String(length=100), nullable=True),
sa.Column('person_id', sa.UUID(), nullable=False),
sa.Column('id', sa.UUID(), nullable=False),
sa.Column('created_at', sa.TIMESTAMP(), nullable=False),
sa.Column('updated_at', sa.TIMESTAMP(), nullable=False),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_addresses_id'), 'addresses', ['id'], unique=False)
op.create_table('contacts',
sa.Column('category', sa.String(length=30), nullable=False),
sa.Column('value', sa.String(length=100), nullable=False),
sa.Column('person_id', sa.UUID(), nullable=False),
sa.Column('id', sa.UUID(), nullable=False),
sa.Column('created_at', sa.TIMESTAMP(), nullable=False),
sa.Column('updated_at', sa.TIMESTAMP(), nullable=False),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_contacts_id'), 'contacts', ['id'], unique=False)
op.create_table('documents',
sa.Column('category', sa.String(length=30), nullable=False),
sa.Column('series', sa.String(length=30), nullable=False),
sa.Column('number', sa.String(length=50), nullable=False),
sa.Column('issued_by', sa.String(length=200), nullable=False),
sa.Column('issued_at', sa.Date(), nullable=True),
sa.Column('person_id', sa.UUID(), nullable=False),
sa.Column('attachments', postgresql.ARRAY(sa.String(length=200)), nullable=True),
sa.Column('id', sa.UUID(), nullable=False),
sa.Column('created_at', sa.TIMESTAMP(), nullable=False),
sa.Column('updated_at', sa.TIMESTAMP(), nullable=False),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_documents_id'), 'documents', ['id'], unique=False)
op.create_table('persons',
sa.Column('first_name', sa.String(length=100), nullable=False),
sa.Column('last_name', sa.String(length=100), nullable=False),
sa.Column('patronymic', sa.String(length=100), nullable=True),
sa.Column('gender', sa.String(length=50), nullable=True),
sa.Column('birth_date', sa.Date(), nullable=True),
sa.Column('photos', postgresql.ARRAY(sa.String(length=200)), nullable=True),
sa.Column('id', sa.UUID(), nullable=False),
sa.Column('created_at', sa.TIMESTAMP(), nullable=False),
sa.Column('updated_at', sa.TIMESTAMP(), nullable=False),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_persons_id'), 'persons', ['id'], unique=False)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index(op.f('ix_persons_id'), table_name='persons')
op.drop_table('persons')
op.drop_index(op.f('ix_documents_id'), table_name='documents')
op.drop_table('documents')
op.drop_index(op.f('ix_contacts_id'), table_name='contacts')
op.drop_table('contacts')
op.drop_index(op.f('ix_addresses_id'), table_name='addresses')
op.drop_table('addresses')
# ### end Alembic commands ###