From a99b7558de9eca56f17c5dd9f730a6352d48f762 Mon Sep 17 00:00:00 2001 From: Bretton May Date: Sun, 16 Nov 2025 17:57:06 -0800 Subject: [PATCH] feat: add database migration for comment namespace update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add migration 018 to update all comment URIs from social.coves.feed.comment to social.coves.community.comment. Migration updates: - comments.uri (main comment URIs) - comments.root_uri (when root is a comment) - comments.parent_uri (when parent is a comment) Includes rollback support via -- +goose Down section for safe reversibility. Since we're pre-production, only the comments table is updated (votes table not affected). Migration file: 018_migrate_comment_namespace.sql 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .../018_migrate_comment_namespace.sql | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 internal/db/migrations/018_migrate_comment_namespace.sql diff --git a/internal/db/migrations/018_migrate_comment_namespace.sql b/internal/db/migrations/018_migrate_comment_namespace.sql new file mode 100644 index 0000000..07341f2 --- /dev/null +++ b/internal/db/migrations/018_migrate_comment_namespace.sql @@ -0,0 +1,34 @@ +-- +goose Up +-- Migration: Update comment URIs from social.coves.feed.comment to social.coves.community.comment +-- This updates the namespace for all comment records in the database. +-- Since we're pre-production, we're only updating the comments table (not votes). + +-- Update main comment URIs +UPDATE comments +SET uri = REPLACE(uri, '/social.coves.feed.comment/', '/social.coves.community.comment/') +WHERE uri LIKE '%/social.coves.feed.comment/%'; + +-- Update root references (when root is a comment, not a post) +UPDATE comments +SET root_uri = REPLACE(root_uri, '/social.coves.feed.comment/', '/social.coves.community.comment/') +WHERE root_uri LIKE '%/social.coves.feed.comment/%'; + +-- Update parent references (when parent is a comment) +UPDATE comments +SET parent_uri = REPLACE(parent_uri, '/social.coves.feed.comment/', '/social.coves.community.comment/') +WHERE parent_uri LIKE '%/social.coves.feed.comment/%'; + +-- +goose Down +-- Rollback: Revert comment URIs from social.coves.community.comment to social.coves.feed.comment + +UPDATE comments +SET uri = REPLACE(uri, '/social.coves.community.comment/', '/social.coves.feed.comment/') +WHERE uri LIKE '%/social.coves.community.comment/%'; + +UPDATE comments +SET root_uri = REPLACE(root_uri, '/social.coves.community.comment/', '/social.coves.feed.comment/') +WHERE root_uri LIKE '%/social.coves.community.comment/%'; + +UPDATE comments +SET parent_uri = REPLACE(parent_uri, '/social.coves.community.comment/', '/social.coves.feed.comment/') +WHERE parent_uri LIKE '%/social.coves.community.comment/%'; -- 2.51.2