"""Add system_settings table for application-wide configuration flags. Revision ID: 002_add_system_settings Revises: 001_widen_ticket_history_values Create Date: 2026-03-30 Rationale --------- Introduces a generic key-value settings store so that runtime configuration flags (such as registration_enabled) can be toggled by administrators through the UI without requiring a code deployment or server restart. Apply ----- flask db upgrade Rollback -------- flask db downgrade """ from alembic import op import sqlalchemy as sa revision = '002_add_system_settings' down_revision = '001_widen_ticket_history_values' branch_labels = None depends_on = None def upgrade(): op.create_table( 'system_settings', sa.Column('id', sa.Integer(), nullable=False), sa.Column('key', sa.String(100), nullable=False), sa.Column('value', sa.String(500), nullable=False), sa.Column('description', sa.String(256), nullable=True), sa.Column('updated_at', sa.DateTime(), nullable=True), sa.PrimaryKeyConstraint('id'), ) op.create_index('ix_system_settings_key', 'system_settings', ['key'], unique=True) # Seed the default: registration is open on fresh installs. op.execute( "INSERT INTO system_settings (key, value, description, updated_at) " "VALUES ('registration_enabled', 'true', " "'Allow new users to self-register via /auth/register', NOW())" ) def downgrade(): op.drop_index('ix_system_settings_key', table_name='system_settings') op.drop_table('system_settings')