polish on archive import processing

This commit is contained in:
Bryan Van Deusen
2025-08-14 16:19:16 -04:00
parent 0d56daa664
commit e9793ba38c
6 changed files with 541 additions and 134 deletions
@@ -0,0 +1,56 @@
"""Add Tag, image_tags, ArchiveRecord
Revision ID: fe4dfdd6616c
Revises: 861f9cae4fe5
Create Date: 2025-08-14 17:57:24.191794
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'fe4dfdd6616c'
down_revision = '861f9cae4fe5'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('tag',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(length=255), nullable=False),
sa.Column('kind', sa.String(length=64), nullable=True),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('name')
)
op.create_table('archive_record',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('filename', sa.String(length=512), nullable=False),
sa.Column('file_size', sa.BigInteger(), nullable=False),
sa.Column('hash', sa.String(length=64), nullable=False),
sa.Column('imported_at', sa.DateTime(), nullable=True),
sa.Column('artist', sa.String(length=255), nullable=True),
sa.Column('tag_id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['tag_id'], ['tag.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('hash')
)
op.create_table('image_tags',
sa.Column('image_id', sa.Integer(), nullable=False),
sa.Column('tag_id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['image_id'], ['image_record.id'], ),
sa.ForeignKeyConstraint(['tag_id'], ['tag.id'], ),
sa.PrimaryKeyConstraint('image_id', 'tag_id'),
sa.UniqueConstraint('image_id', 'tag_id', name='uq_image_tag')
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('image_tags')
op.drop_table('archive_record')
op.drop_table('tag')
# ### end Alembic commands ###