73 lines
3.0 KiB
Python
73 lines
3.0 KiB
Python
"""initial migration
|
|
|
|
Revision ID: 936d19bcafbf
|
|
Revises:
|
|
Create Date: 2024-10-06 17:53:11.262950
|
|
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = '936d19bcafbf'
|
|
down_revision = None
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.create_table('roles',
|
|
sa.Column('id', sa.Integer(), autoincrement=False, nullable=False),
|
|
sa.Column('name', sa.String(length=100), nullable=False),
|
|
sa.Column('createdAt', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
|
|
sa.Column('updatedAt', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
|
|
sa.PrimaryKeyConstraint('id'),
|
|
sa.UniqueConstraint('name')
|
|
)
|
|
op.create_table('staff',
|
|
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
|
sa.Column('firstName', sa.String(length=40), nullable=False),
|
|
sa.Column('lastName', sa.String(length=40), nullable=False),
|
|
sa.Column('uid', sa.String(length=100), nullable=False),
|
|
sa.Column('email', sa.String(length=100), nullable=False),
|
|
sa.Column('password', sa.String(length=200), nullable=True),
|
|
sa.Column('dateOfBirth', sa.DateTime(timezone=True), nullable=True),
|
|
sa.Column('roleId', sa.Integer(), nullable=False),
|
|
sa.Column('revoked', sa.Boolean(), nullable=False),
|
|
sa.Column('createdAt', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
|
|
sa.Column('updatedAt', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
|
|
sa.ForeignKeyConstraint(['roleId'], ['roles.id'], ),
|
|
sa.PrimaryKeyConstraint('id'),
|
|
sa.UniqueConstraint('email'),
|
|
sa.UniqueConstraint('uid')
|
|
)
|
|
with op.batch_alter_table('staff', schema=None) as batch_op:
|
|
batch_op.create_index(batch_op.f('ix_staff_firstName'), ['firstName'], unique=False)
|
|
batch_op.create_index(batch_op.f('ix_staff_lastName'), ['lastName'], unique=False)
|
|
|
|
op.create_table('email_aliases',
|
|
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
|
sa.Column('email', sa.String(length=100), nullable=False),
|
|
sa.Column('staffId', sa.Integer(), nullable=False),
|
|
sa.Column('createdAt', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
|
|
sa.Column('updatedAt', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
|
|
sa.ForeignKeyConstraint(['staffId'], ['staff.id'], ),
|
|
sa.PrimaryKeyConstraint('id'),
|
|
sa.UniqueConstraint('email')
|
|
)
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.drop_table('email_aliases')
|
|
with op.batch_alter_table('staff', schema=None) as batch_op:
|
|
batch_op.drop_index(batch_op.f('ix_staff_lastName'))
|
|
batch_op.drop_index(batch_op.f('ix_staff_firstName'))
|
|
|
|
op.drop_table('staff')
|
|
op.drop_table('roles')
|
|
# ### end Alembic commands ###
|