95 lines
4.6 KiB
Python
95 lines
4.6 KiB
Python
|
|
"""empty message
|
||
|
|
|
||
|
|
Revision ID: 63d014f73934
|
||
|
|
Revises: 3bfaa1b74794
|
||
|
|
Create Date: 2023-12-02 21:50:41.457594
|
||
|
|
|
||
|
|
"""
|
||
|
|
from alembic import op
|
||
|
|
import sqlalchemy as sa
|
||
|
|
|
||
|
|
|
||
|
|
# revision identifiers, used by Alembic.
|
||
|
|
revision = '63d014f73934'
|
||
|
|
down_revision = '3bfaa1b74794'
|
||
|
|
branch_labels = None
|
||
|
|
depends_on = None
|
||
|
|
|
||
|
|
|
||
|
|
def upgrade() -> None:
|
||
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
||
|
|
op.create_table('user',
|
||
|
|
sa.Column('id', sa.BigInteger(), nullable=False),
|
||
|
|
sa.Column('username', sa.String(length=30), nullable=True),
|
||
|
|
sa.Column('display_name', sa.String(length=64), nullable=True),
|
||
|
|
sa.Column('passhash', sa.String(length=256), nullable=True),
|
||
|
|
sa.Column('joined_at', sa.String(length=256), nullable=True),
|
||
|
|
sa.PrimaryKeyConstraint('id'),
|
||
|
|
sa.UniqueConstraint('username')
|
||
|
|
)
|
||
|
|
op.create_table('imagecollection',
|
||
|
|
sa.Column('id', sa.BigInteger(), nullable=False),
|
||
|
|
sa.Column('name', sa.String(length=128), nullable=False),
|
||
|
|
sa.Column('owner_id', sa.BigInteger(), nullable=True),
|
||
|
|
sa.Column('description', sa.String(length=4096), nullable=True),
|
||
|
|
sa.ForeignKeyConstraint(['owner_id'], ['user.id'], ),
|
||
|
|
sa.PrimaryKeyConstraint('id')
|
||
|
|
)
|
||
|
|
op.create_table('imageincollection',
|
||
|
|
sa.Column('image_id', sa.BigInteger(), nullable=False),
|
||
|
|
sa.Column('collection_id', sa.BigInteger(), nullable=False),
|
||
|
|
sa.Column('since', sa.DateTime(), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=True),
|
||
|
|
sa.ForeignKeyConstraint(['collection_id'], ['imagecollection.id'], ),
|
||
|
|
sa.ForeignKeyConstraint(['image_id'], ['image.id'], ),
|
||
|
|
sa.PrimaryKeyConstraint('image_id', 'collection_id')
|
||
|
|
)
|
||
|
|
op.create_index(op.f('ix_imageincollection_since'), 'imageincollection', ['since'], unique=False)
|
||
|
|
op.drop_index('idx_60001_image_date', table_name='image')
|
||
|
|
op.drop_index('idx_60001_image_hash', table_name='image')
|
||
|
|
op.drop_index('idx_60001_image_name', table_name='image')
|
||
|
|
op.drop_index('idx_60001_image_pathname', table_name='image')
|
||
|
|
op.drop_index('idx_60001_image_type', table_name='image')
|
||
|
|
op.create_index(op.f('ix_image_date'), 'image', ['date'], unique=False)
|
||
|
|
op.create_index(op.f('ix_image_hash'), 'image', ['hash'], unique=False)
|
||
|
|
op.create_index(op.f('ix_image_name'), 'image', ['name'], unique=False)
|
||
|
|
op.create_index(op.f('ix_image_type'), 'image', ['type'], unique=False)
|
||
|
|
op.create_unique_constraint(None, 'image', ['pathname'])
|
||
|
|
op.drop_index('idx_59995_imagetag_image_id', table_name='imagetag')
|
||
|
|
op.drop_index('idx_59995_imagetag_image_id_name', table_name='imagetag')
|
||
|
|
op.create_unique_constraint(None, 'imagetag', ['image_id', 'name'])
|
||
|
|
op.create_foreign_key(None, 'imagetag', 'image', ['image_id'], ['id'])
|
||
|
|
op.create_index(op.f('ix_video_date'), 'video', ['date'], unique=False)
|
||
|
|
op.create_index(op.f('ix_video_duration'), 'video', ['duration'], unique=False)
|
||
|
|
op.create_index(op.f('ix_video_name'), 'video', ['name'], unique=False)
|
||
|
|
op.create_index(op.f('ix_video_type'), 'video', ['type'], unique=False)
|
||
|
|
op.create_unique_constraint(None, 'video', ['pathname'])
|
||
|
|
# ### end Alembic commands ###
|
||
|
|
|
||
|
|
|
||
|
|
def downgrade() -> None:
|
||
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
||
|
|
op.drop_constraint(None, 'video', type_='unique')
|
||
|
|
op.drop_index(op.f('ix_video_type'), table_name='video')
|
||
|
|
op.drop_index(op.f('ix_video_name'), table_name='video')
|
||
|
|
op.drop_index(op.f('ix_video_duration'), table_name='video')
|
||
|
|
op.drop_index(op.f('ix_video_date'), table_name='video')
|
||
|
|
op.drop_constraint(None, 'imagetag', type_='foreignkey')
|
||
|
|
op.drop_constraint(None, 'imagetag', type_='unique')
|
||
|
|
op.create_index('idx_59995_imagetag_image_id_name', 'imagetag', ['image_id', 'name'], unique=False)
|
||
|
|
op.create_index('idx_59995_imagetag_image_id', 'imagetag', ['image_id'], unique=False)
|
||
|
|
op.drop_constraint(None, 'image', type_='unique')
|
||
|
|
op.drop_index(op.f('ix_image_type'), table_name='image')
|
||
|
|
op.drop_index(op.f('ix_image_name'), table_name='image')
|
||
|
|
op.drop_index(op.f('ix_image_hash'), table_name='image')
|
||
|
|
op.drop_index(op.f('ix_image_date'), table_name='image')
|
||
|
|
op.create_index('idx_60001_image_type', 'image', ['type'], unique=False)
|
||
|
|
op.create_index('idx_60001_image_pathname', 'image', ['pathname'], unique=False)
|
||
|
|
op.create_index('idx_60001_image_name', 'image', ['name'], unique=False)
|
||
|
|
op.create_index('idx_60001_image_hash', 'image', ['hash'], unique=False)
|
||
|
|
op.create_index('idx_60001_image_date', 'image', ['date'], unique=False)
|
||
|
|
op.drop_index(op.f('ix_imageincollection_since'), table_name='imageincollection')
|
||
|
|
op.drop_table('imageincollection')
|
||
|
|
op.drop_table('imagecollection')
|
||
|
|
op.drop_table('user')
|
||
|
|
# ### end Alembic commands ###
|