Add migration for School
This commit is contained in:
parent
d6699b157a
commit
8800860562
40
alembic/versions/20250327_212011_9cd61297_create_school.py
Normal file
40
alembic/versions/20250327_212011_9cd61297_create_school.py
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
"""create schools table
|
||||||
|
|
||||||
|
Revision ID: b2c3d4e5f6g7
|
||||||
|
Revises:
|
||||||
|
Create Date: 2024-01-09 10:00:00.000000
|
||||||
|
"""
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
from sqlalchemy.sql import func
|
||||||
|
import uuid
|
||||||
|
|
||||||
|
# revision identifiers
|
||||||
|
revision = 'b2c3d4e5f6g7'
|
||||||
|
down_revision = None
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
op.create_table(
|
||||||
|
'schools',
|
||||||
|
sa.Column('id', sa.String(), primary_key=True, default=lambda: str(uuid.uuid4())),
|
||||||
|
sa.Column('name', sa.String(), nullable=False),
|
||||||
|
sa.Column('address', sa.String(), nullable=False),
|
||||||
|
sa.Column('capacity', sa.Integer(), nullable=False),
|
||||||
|
sa.Column('storage_type', sa.String(), nullable=False),
|
||||||
|
sa.Column('temperature_controlled', sa.Boolean(), default=False),
|
||||||
|
sa.Column('security_level', sa.String(), nullable=False),
|
||||||
|
sa.Column('is_active', sa.Boolean(), default=True),
|
||||||
|
sa.Column('square_footage', sa.Integer(), nullable=False),
|
||||||
|
sa.Column('available_space', sa.Integer(), nullable=False),
|
||||||
|
sa.Column('created_at', sa.DateTime(), server_default=sa.func.now()),
|
||||||
|
sa.Column('updated_at', sa.DateTime(), server_default=sa.func.now(), onupdate=sa.func.now()),
|
||||||
|
sa.PrimaryKeyConstraint('id')
|
||||||
|
)
|
||||||
|
|
||||||
|
op.create_index('ix_schools_name', 'schools', ['name'])
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
op.drop_index('ix_schools_name', 'schools')
|
||||||
|
op.drop_table('schools')
|
Loading…
x
Reference in New Issue
Block a user