[FWA-5] Home Create and List
This commit is contained in:
64
alembic/versions/0fbca538155d_create_house_and_area_table.py
Normal file
64
alembic/versions/0fbca538155d_create_house_and_area_table.py
Normal file
@ -0,0 +1,64 @@
|
||||
"""create house and area table
|
||||
|
||||
Revision ID: 0fbca538155d
|
||||
Revises: 4b90a6ac504b
|
||||
Create Date: 2024-06-30 05:38:20.062935
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
import backend.db.migration_types
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '0fbca538155d'
|
||||
down_revision: Union[str, None] = '4b90a6ac504b'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('houses',
|
||||
sa.Column('id', backend.db.models.guid.GUID(), nullable=False),
|
||||
sa.Column('icon', sa.String(), nullable=False),
|
||||
sa.Column('name', sa.String(), nullable=False),
|
||||
sa.Column('address', sa.String(), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=True),
|
||||
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
||||
sa.Column('deleted_at', sa.DateTime(), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index(op.f('ix_houses_created_at'), 'houses', ['created_at'], unique=False)
|
||||
op.create_index(op.f('ix_houses_id'), 'houses', ['id'], unique=False)
|
||||
op.create_index(op.f('ix_houses_name'), 'houses', ['name'], unique=False)
|
||||
op.create_table('areas',
|
||||
sa.Column('id', backend.db.models.guid.GUID(), nullable=False),
|
||||
sa.Column('house_id', backend.db.models.guid.GUID(), nullable=False),
|
||||
sa.Column('name', sa.String(), nullable=False),
|
||||
sa.Column('desc', sa.String(), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=True),
|
||||
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
||||
sa.Column('deleted_at', sa.DateTime(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['house_id'], ['houses.id'], ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index(op.f('ix_areas_created_at'), 'areas', ['created_at'], unique=False)
|
||||
op.create_index(op.f('ix_areas_id'), 'areas', ['id'], unique=False)
|
||||
op.create_index(op.f('ix_areas_name'), 'areas', ['name'], unique=False)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_index(op.f('ix_areas_name'), table_name='areas')
|
||||
op.drop_index(op.f('ix_areas_id'), table_name='areas')
|
||||
op.drop_index(op.f('ix_areas_created_at'), table_name='areas')
|
||||
op.drop_table('areas')
|
||||
op.drop_index(op.f('ix_houses_name'), table_name='houses')
|
||||
op.drop_index(op.f('ix_houses_id'), table_name='houses')
|
||||
op.drop_index(op.f('ix_houses_created_at'), table_name='houses')
|
||||
op.drop_table('houses')
|
||||
# ### end Alembic commands ###
|
Reference in New Issue
Block a user