49 lines
1.8 KiB
Python
49 lines
1.8 KiB
Python
"""Add printeditemfiles: append-only print-file revisions per item.
|
|
|
|
The plugin's first incremental migration on top of its 0001 baseline -
|
|
the ADR-008 payoff: the plugin evolves its own schema without touching
|
|
the core chain. Applied by `flask plugin upgrade-all`.
|
|
"""
|
|
from alembic import op
|
|
|
|
from shopdb.plugins.alembic_template import (
|
|
create_index_if_missing,
|
|
create_table_if_missing,
|
|
)
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = 'printedparts0002files'
|
|
down_revision = 'printedparts0001baseline'
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade():
|
|
create_table_if_missing(
|
|
'printeditemfiles',
|
|
sa.Column('fileid', sa.Integer(), nullable=False),
|
|
sa.Column('printeditemid', sa.Integer(), nullable=False),
|
|
sa.Column('revision', sa.Integer(), nullable=False),
|
|
sa.Column('filename', sa.String(length=255), nullable=False),
|
|
sa.Column('storedfilename', sa.String(length=191), nullable=False),
|
|
sa.Column('filesize', sa.Integer(), nullable=False),
|
|
sa.Column('uploadnote', sa.String(length=255), nullable=True),
|
|
sa.Column('uploadedby', sa.String(length=80), nullable=False),
|
|
sa.Column('createddate', sa.DateTime(), nullable=False),
|
|
sa.Column('modifieddate', sa.DateTime(), nullable=False),
|
|
sa.Column('isactive', sa.Boolean(), nullable=False),
|
|
sa.ForeignKeyConstraint(['printeditemid'],
|
|
['printeditems.printeditemid'],
|
|
ondelete='CASCADE'),
|
|
sa.PrimaryKeyConstraint('fileid'),
|
|
sa.UniqueConstraint('storedfilename'),
|
|
)
|
|
create_index_if_missing('ix_printeditemfiles_printeditemid',
|
|
'printeditemfiles', ['printeditemid'])
|
|
|
|
|
|
def downgrade():
|
|
op.drop_table('printeditemfiles')
|