Implement task 006 site config versioning and audit events
This commit is contained in:
@@ -285,6 +285,17 @@ POSTGRES_SCHEMA_STATEMENTS: tuple[str, ...] = (
|
||||
UNIQUE (prompt_key, version)
|
||||
)
|
||||
""",
|
||||
f"""
|
||||
CREATE TABLE IF NOT EXISTS script_config_version_events (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
target_site_id UUID NOT NULL REFERENCES target_sites(id) ON DELETE CASCADE,
|
||||
version_id UUID NOT NULL REFERENCES script_config_versions(id) ON DELETE CASCADE,
|
||||
event_type TEXT NOT NULL,
|
||||
actor_user_id UUID REFERENCES users(id),
|
||||
payload JSONB NOT NULL DEFAULT '{{}}'::jsonb,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
||||
)
|
||||
""",
|
||||
"CREATE INDEX IF NOT EXISTS idx_target_sites_slug ON target_sites (slug)",
|
||||
"""
|
||||
CREATE INDEX IF NOT EXISTS idx_articles_dashboard
|
||||
@@ -314,6 +325,10 @@ POSTGRES_SCHEMA_STATEMENTS: tuple[str, ...] = (
|
||||
CREATE INDEX IF NOT EXISTS idx_publish_commits_article
|
||||
ON publish_commits (article_id, created_at)
|
||||
""",
|
||||
"""
|
||||
CREATE INDEX IF NOT EXISTS idx_script_config_version_events_site
|
||||
ON script_config_version_events (target_site_id, created_at)
|
||||
""",
|
||||
)
|
||||
|
||||
|
||||
@@ -550,6 +565,17 @@ SQLITE_SCHEMA_STATEMENTS: tuple[str, ...] = (
|
||||
UNIQUE (prompt_key, version)
|
||||
)
|
||||
""",
|
||||
"""
|
||||
CREATE TABLE IF NOT EXISTS script_config_version_events (
|
||||
id TEXT PRIMARY KEY,
|
||||
target_site_id TEXT NOT NULL,
|
||||
version_id TEXT NOT NULL,
|
||||
event_type TEXT NOT NULL,
|
||||
actor_user_id TEXT,
|
||||
payload TEXT NOT NULL DEFAULT '{}',
|
||||
created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
)
|
||||
""",
|
||||
"CREATE INDEX IF NOT EXISTS idx_target_sites_slug ON target_sites (slug)",
|
||||
"""
|
||||
CREATE INDEX IF NOT EXISTS idx_articles_dashboard
|
||||
@@ -579,6 +605,10 @@ SQLITE_SCHEMA_STATEMENTS: tuple[str, ...] = (
|
||||
CREATE INDEX IF NOT EXISTS idx_publish_commits_article
|
||||
ON publish_commits (article_id, created_at)
|
||||
""",
|
||||
"""
|
||||
CREATE INDEX IF NOT EXISTS idx_script_config_version_events_site
|
||||
ON script_config_version_events (target_site_id, created_at)
|
||||
""",
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user