Files
StarPunk/migrations/018_foreign_key_cleanup.sql
T
PhilandClaude Opus 5.5 75946be7b2 maint: Dependency upgrades and High backlog items (v2.11.0)
- All dependencies to current releases (97 known vulnerabilities -> 0),
  Python 3.14, uv pinned, requirements-test.txt, lxml/dateutil pinned
- CSRF tokens on admin forms, logout and IndieAuth consent
- IndieAuth client and crosspost link-card fetches via safe_get
- FLASK_DEBUG/FLASK_ENV default off/production; image sets them
- Foreign keys enforced on pooled connections; migration 018 removes orphans
- Rate limits shared across processes (rate_limits, migration 019)
- datetime.utcnow() and sqlite3 default adapters replaced
- compose.yaml fixed; duplicate dev_auth.py and test.ini removed

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 13:09:52 -07:00

13 lines
953 B
SQL

-- Migration 018: Remove rows orphaned while foreign keys weren't enforced (v2.11.0)
-- From v2.11.0 every pooled connection runs PRAGMA foreign_keys=ON, so these
-- cascades happen on delete. This removes what earlier deletes left behind.
DELETE FROM note_tags WHERE note_id NOT IN (SELECT id FROM notes);
DELETE FROM note_tags WHERE tag_id NOT IN (SELECT id FROM tags);
DELETE FROM note_media WHERE note_id NOT IN (SELECT id FROM notes);
DELETE FROM note_media WHERE media_id NOT IN (SELECT id FROM media);
DELETE FROM media_variants WHERE media_id NOT IN (SELECT id FROM media);
DELETE FROM webmention_queue WHERE source_note_id IS NOT NULL AND source_note_id NOT IN (SELECT id FROM notes);
UPDATE webmentions SET target_note_id = NULL WHERE target_note_id IS NOT NULL AND target_note_id NOT IN (SELECT id FROM notes);
DELETE FROM websub_deliveries WHERE subscription_id IS NOT NULL AND subscription_id NOT IN (SELECT id FROM websub_subscriptions);