fix: disabling last store/group no longer resets all to enabled
Added store_filters_seeded / group_filters_seeded flags to SyncConfig. _enabled_*_ids now returns None (all enabled) only before first toggle, not when the filter table is empty due to all being disabled. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
"""Add store_filters_seeded and group_filters_seeded to sync_configs."""
|
||||
revision = "0011"
|
||||
down_revision = "0010"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.add_column("sync_configs", sa.Column("store_filters_seeded", sa.Boolean(), nullable=False, server_default="0"))
|
||||
op.add_column("sync_configs", sa.Column("group_filters_seeded", sa.Boolean(), nullable=False, server_default="0"))
|
||||
|
||||
# Mark existing rows as seeded if they already have filters
|
||||
op.execute("""
|
||||
UPDATE sync_configs sc
|
||||
SET store_filters_seeded = 1
|
||||
WHERE EXISTS (
|
||||
SELECT 1 FROM sync_filters sf
|
||||
WHERE sf.sync_config_id = sc.id AND sf.entity_type = 'store'
|
||||
)
|
||||
""")
|
||||
op.execute("""
|
||||
UPDATE sync_configs sc
|
||||
SET group_filters_seeded = 1
|
||||
WHERE EXISTS (
|
||||
SELECT 1 FROM sync_filters sf
|
||||
WHERE sf.sync_config_id = sc.id AND sf.entity_type = 'group'
|
||||
)
|
||||
""")
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_column("sync_configs", "group_filters_seeded")
|
||||
op.drop_column("sync_configs", "store_filters_seeded")
|
||||
Reference in New Issue
Block a user