mirror of
https://github.com/jhd3197/ServerKit.git
synced 2026-12-01 20:55:16 +09:00
Phase 1 of the July-5-7 recovery rebuild (plan 38). Backend now boots. - models: reconstruct DnsCutoverSnapshot (from bytecode) + FleetDoctorResult (from migration 063 DDL); restore lost columns applications.ports/ bootstrap_done, app_volumes.declared_size, dns_provider_configs.origin_ca_key - migrations: recreate the 15 missing revisions 056/057/060/062/063/064/065/ 067/068/069/070-074, reconciling the chain to a single linear head (074). add_column revisions guard on live schema so a fresh-DB upgrade reaches head - rbac: restore _APP_ROLE_RANK + require_workspace_access/require_workspace_role/ app_access_tier/require_app_member (plan 19/29 4-tier authz), recovered from bytecode; unblocks api/cron.py import - services: reconstruct cron_run_service.CronRunService (record_run/recent_runs/ stats, edge-triggered failure/recovery transitions) from bytecode Gate: create_app() imports clean, db.create_all() OK, flask db upgrade on a fresh SQLite DB reaches head 074 (linear chain). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
61 lines
2.5 KiB
Python
61 lines
2.5 KiB
Python
"""Per-zone Cloudflare-ops activity ledger (plan 36 #10).
|
|
|
|
Adds ``cf_ops_changes`` — the ops-layer sibling of ``dns_changes`` — recording
|
|
every Cloudflare zone-operations write ServerKit makes (settings, DNSSEC, WAF,
|
|
redirect/transform rules, Origin CA, Workers, Tunnels, storage), keyed by
|
|
``provider_zone_id`` for the per-zone Activity tab.
|
|
|
|
Idempotent: MigrationService runs _fix_missing_columns() + db.create_all() on
|
|
boot before Alembic, so guard on the live schema (the table may already exist).
|
|
|
|
Revision ID: 074_cf_ops_changes
|
|
Revises: 073_dns_provider_origin_ca_key
|
|
Create Date: 2026-07-07
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
revision = '074_cf_ops_changes'
|
|
down_revision = '073_dns_provider_origin_ca_key'
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade():
|
|
conn = op.get_bind()
|
|
inspector = sa.inspect(conn)
|
|
tables = set(inspector.get_table_names())
|
|
|
|
if 'cf_ops_changes' not in tables:
|
|
op.create_table(
|
|
'cf_ops_changes',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('dns_provider_config_id', sa.Integer(), nullable=True),
|
|
sa.Column('provider_zone_id', sa.String(length=128), nullable=True),
|
|
sa.Column('product', sa.String(length=32), nullable=False),
|
|
sa.Column('action', sa.String(length=32), nullable=False),
|
|
sa.Column('target', sa.String(length=256), nullable=True),
|
|
sa.Column('result', sa.String(length=16), nullable=False,
|
|
server_default='ok'),
|
|
sa.Column('error', sa.Text(), nullable=True),
|
|
sa.Column('user_id', sa.Integer(), nullable=True),
|
|
sa.Column('created_at', sa.DateTime(), nullable=True),
|
|
sa.ForeignKeyConstraint(['dns_provider_config_id'],
|
|
['dns_provider_configs.id']),
|
|
sa.ForeignKeyConstraint(['user_id'], ['users.id']),
|
|
sa.PrimaryKeyConstraint('id'),
|
|
)
|
|
op.create_index('ix_cf_ops_changes_dns_provider_config_id',
|
|
'cf_ops_changes', ['dns_provider_config_id'])
|
|
op.create_index('ix_cf_ops_changes_provider_zone_id',
|
|
'cf_ops_changes', ['provider_zone_id'])
|
|
op.create_index('ix_cf_ops_changes_created_at',
|
|
'cf_ops_changes', ['created_at'])
|
|
|
|
|
|
def downgrade():
|
|
conn = op.get_bind()
|
|
inspector = sa.inspect(conn)
|
|
if 'cf_ops_changes' in set(inspector.get_table_names()):
|
|
op.drop_table('cf_ops_changes')
|