|
| 1 | +"""initialize models |
| 2 | +
|
| 3 | +Revision ID: cd5b3c3d1cd2 |
| 4 | +Revises: |
| 5 | +Create Date: 2026-04-28 01:24:30.407103 |
| 6 | +
|
| 7 | +""" |
| 8 | +from typing import Sequence, Union |
| 9 | + |
| 10 | +from alembic import op |
| 11 | +import sqlalchemy as sa |
| 12 | +import sqlmodel.sql.sqltypes |
| 13 | + |
| 14 | + |
| 15 | +# revision identifiers, used by Alembic. |
| 16 | +revision: str = 'cd5b3c3d1cd2' |
| 17 | +down_revision: Union[str, Sequence[str], None] = None |
| 18 | +branch_labels: Union[str, Sequence[str], None] = None |
| 19 | +depends_on: Union[str, Sequence[str], None] = None |
| 20 | + |
| 21 | + |
| 22 | +def upgrade() -> None: |
| 23 | + """Upgrade schema.""" |
| 24 | + # ### commands auto generated by Alembic - please adjust! ### |
| 25 | + op.create_table( |
| 26 | + 'user', |
| 27 | + sa.Column('email', sqlmodel.sql.sqltypes.AutoString(), nullable=False), |
| 28 | + sa.Column('is_active', sa.Boolean(), nullable=False), |
| 29 | + sa.Column('is_superuser', sa.Boolean(), nullable=False), |
| 30 | + sa.Column('full_name', sqlmodel.sql.sqltypes.AutoString(), nullable=True), |
| 31 | + sa.Column('id', sa.UUID(), nullable=False), |
| 32 | + sa.Column('hashed_password', sqlmodel.sql.sqltypes.AutoString(), nullable=False), |
| 33 | + sa.Column('created_at', sa.DateTime(timezone=True), nullable=True), |
| 34 | + sa.PrimaryKeyConstraint('id'), |
| 35 | + ) |
| 36 | + op.create_index(op.f('ix_user_email'), 'user', ['email'], unique=True) |
| 37 | + op.create_table( |
| 38 | + 'item', |
| 39 | + sa.Column('title', sqlmodel.sql.sqltypes.AutoString(), nullable=False), |
| 40 | + sa.Column('description', sqlmodel.sql.sqltypes.AutoString(), nullable=True), |
| 41 | + sa.Column('id', sa.UUID(), nullable=False), |
| 42 | + sa.Column('created_at', sa.DateTime(timezone=True), nullable=True), |
| 43 | + sa.Column('owner_id', sa.UUID(), nullable=False), |
| 44 | + sa.ForeignKeyConstraint(['owner_id'], ['user.id'], ondelete='CASCADE'), |
| 45 | + sa.PrimaryKeyConstraint('id'), |
| 46 | + ) |
| 47 | + # ### end Alembic commands ### |
| 48 | + |
| 49 | + |
| 50 | +def downgrade() -> None: |
| 51 | + """Downgrade schema.""" |
| 52 | + # ### commands auto generated by Alembic - please adjust! ### |
| 53 | + op.drop_table('item') |
| 54 | + op.drop_index(op.f('ix_user_email'), table_name='user') |
| 55 | + op.drop_table('user') |
| 56 | + # ### end Alembic commands ### |
0 commit comments