Plugin baselines skip tables that already exist

This commit is contained in:
2026-08-24 09:28:52 -04:00
parent ce3a0f4338
commit f109dd1349
12 changed files with 285 additions and 74 deletions

View File

@@ -11,6 +11,11 @@ ops are written out explicitly anyway to match the measuringtools exemplar
and keep the baseline reviewable.
"""
from alembic import op
from shopdb.plugins.alembic_template import (
create_index_if_missing,
create_table_if_missing,
)
import sqlalchemy as sa
@@ -22,7 +27,7 @@ depends_on = None
def upgrade():
op.create_table(
create_table_if_missing(
'printeditems',
sa.Column('printeditemid', sa.Integer(), nullable=False),
sa.Column('itemcode', sa.String(length=20), nullable=True),
@@ -39,9 +44,9 @@ def upgrade():
sa.PrimaryKeyConstraint('printeditemid'),
sa.UniqueConstraint('itemcode'),
)
op.create_index('ix_printeditems_itemcode', 'printeditems', ['itemcode'])
create_index_if_missing('ix_printeditems_itemcode', 'printeditems', ['itemcode'])
op.create_table(
create_table_if_missing(
'printeditemtransactions',
sa.Column('transactionid', sa.Integer(), nullable=False),
sa.Column('printeditemid', sa.Integer(), nullable=False),
@@ -58,12 +63,12 @@ def upgrade():
ondelete='CASCADE'),
sa.PrimaryKeyConstraint('transactionid'),
)
op.create_index('ix_printeditemtransactions_printeditemid',
'printeditemtransactions', ['printeditemid'])
op.create_index('ix_printeditemtransactions_employeesso',
'printeditemtransactions', ['employeesso'])
op.create_index('ix_printeditemtransactions_transactiondate',
'printeditemtransactions', ['transactiondate'])
create_index_if_missing('ix_printeditemtransactions_printeditemid',
'printeditemtransactions', ['printeditemid'])
create_index_if_missing('ix_printeditemtransactions_employeesso',
'printeditemtransactions', ['employeesso'])
create_index_if_missing('ix_printeditemtransactions_transactiondate',
'printeditemtransactions', ['transactiondate'])
def downgrade():