Rustelo/resources/user-dashboard/migrations/004_gdpr_bookmarks_postgres.sql
Jesús Pérez f1010e9d07
chore: update
2026-07-18 20:16:16 +01:00

17 lines
644 B
SQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- Migration: 004 GDPR consent timestamp + user bookmarks
-- Database: PostgreSQL
ALTER TABLE users ADD COLUMN IF NOT EXISTS gdpr_accepted_at TIMESTAMPTZ;
CREATE TABLE IF NOT EXISTS user_bookmarks (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
content_type VARCHAR(50) NOT NULL,
content_id VARCHAR(255) NOT NULL,
content_title VARCHAR(500),
content_url VARCHAR(500),
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
UNIQUE(user_id, content_type, content_id)
);
CREATE INDEX IF NOT EXISTS idx_user_bookmarks_user_id ON user_bookmarks(user_id);