likwid/backend/migrations_demo/20260128114000_demo_moderation_log_deterministic_ids.sql
Marco Allegretti f37033567a backend: add 4 files, rename 1 file
Verified changes:
- add backend/migrations/20260128113000_moderation_ledger_delete_guard_fix.sql
- rename backend/migrations/20260127150000_demo_seed_data.sql -> backend/migrations_demo/20260127150000_demo_seed_data.sql
- add backend/migrations_demo/20260128114000_demo_moderation_log_deterministic_ids.sql
- add backend/migrations_demo/20260128115000_demo_seed_user_roles.sql
- add backend/migrations_demo/20260128130000_demo_convert_topic_delegations_to_community.sql

Diffstat:
- 5 files changed, 114 insertions(+)
2026-01-29 00:37:50 +01:00

55 lines
2.4 KiB
SQL

-- Assign deterministic IDs to seeded moderation_log rows so demo reset can preserve baseline logs.
-- RFC-001 description edit
WITH seed_row AS (
SELECT id
FROM moderation_log
WHERE community_id = 'c0000001-0000-0000-0000-000000000001'::uuid
AND moderator_id = 'd0000001-0000-0000-0000-000000000002'::uuid
AND target_user_id IS NULL
AND action_type = 'content_edit'
AND reason = 'Updated RFC-001 description for clarity'
AND details = '{"proposal_id": "b0000001-0000-0000-0000-000000000001", "field": "description", "change_type": "formatting"}'::jsonb
ORDER BY created_at
LIMIT 1
)
UPDATE moderation_log
SET id = 'f0000001-0000-0000-0000-000000000001'::uuid
WHERE id IN (SELECT id FROM seed_row)
AND NOT EXISTS (SELECT 1 FROM moderation_log WHERE id = 'f0000001-0000-0000-0000-000000000001'::uuid);
-- Budget proposal thread warning
WITH seed_row AS (
SELECT id
FROM moderation_log
WHERE community_id = 'c0000001-0000-0000-0000-000000000002'::uuid
AND moderator_id = 'd0000001-0000-0000-0000-000000000002'::uuid
AND target_user_id = 'd0000002-0000-0000-0000-000000000009'::uuid
AND action_type = 'warning'
AND reason = 'Off-topic discussion in budget proposal thread'
AND details = '{"rule": "community_guidelines_3", "comment_id": "comment_example_001"}'::jsonb
ORDER BY created_at
LIMIT 1
)
UPDATE moderation_log
SET id = 'f0000001-0000-0000-0000-000000000002'::uuid
WHERE id IN (SELECT id FROM seed_row)
AND NOT EXISTS (SELECT 1 FROM moderation_log WHERE id = 'f0000001-0000-0000-0000-000000000002'::uuid);
-- Proposal deadline extension
WITH seed_row AS (
SELECT id
FROM moderation_log
WHERE community_id = 'c0000001-0000-0000-0000-000000000003'::uuid
AND moderator_id = 'd0000001-0000-0000-0000-000000000002'::uuid
AND target_user_id IS NULL
AND action_type = 'proposal_extended'
AND reason = 'Extended voting deadline by 48 hours due to technical issues'
AND details = '{"proposal_id": "b0000001-0000-0000-0000-000000000006", "original_end": "2026-01-10T00:00:00Z", "new_end": "2026-01-12T00:00:00Z"}'::jsonb
ORDER BY created_at
LIMIT 1
)
UPDATE moderation_log
SET id = 'f0000001-0000-0000-0000-000000000003'::uuid
WHERE id IN (SELECT id FROM seed_row)
AND NOT EXISTS (SELECT 1 FROM moderation_log WHERE id = 'f0000001-0000-0000-0000-000000000003'::uuid);