blog/backend/migrations/20251011200359_add_semantic_id_to_post.sql

8 lines
304 B
SQL

ALTER TABLE post ADD COLUMN "semantic_id" VARCHAR(100) NOT NULL DEFAULT '';
-- Update existing records to use their id as semantic_id
UPDATE post SET semantic_id = id::VARCHAR WHERE semantic_id = '';
-- Create unique index on semantic_id
CREATE UNIQUE INDEX idx_post_semantic_id ON post (semantic_id);