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

@@ -12,6 +12,11 @@ plugin's tables, so the foreign key to the core users table cannot resolve at
CreateTable-compile time.
"""
from alembic import op
from shopdb.plugins.alembic_template import (
create_index_if_missing,
create_table_if_missing,
)
import sqlalchemy as sa
@@ -23,7 +28,7 @@ depends_on = None
def upgrade():
op.create_table(
create_table_if_missing(
'securesendsecrets',
sa.Column('secretid', sa.Integer(), nullable=False),
# 128 bits of randomness as hex. With no login on the read side this is
@@ -47,13 +52,13 @@ def upgrade():
)
# Unique, because the token is looked up on every read and two rows sharing
# one would make a link ambiguous.
op.create_index('ixsecuresendsecretstoken', 'securesendsecrets',
['token'], unique=True)
create_index_if_missing('ixsecuresendsecretstoken', 'securesendsecrets',
['token'], unique=True)
# Expiry sweeps scan on this.
op.create_index('ixsecuresendsecretsexpiresat', 'securesendsecrets',
['expiresat'])
op.create_index('ixsecuresendsecretscreatedby', 'securesendsecrets',
['createdbyuserid'])
create_index_if_missing('ixsecuresendsecretsexpiresat', 'securesendsecrets',
['expiresat'])
create_index_if_missing('ixsecuresendsecretscreatedby', 'securesendsecrets',
['createdbyuserid'])
def downgrade():