Migrations: - Fix 010_seed_super_admin.sql: only use columns from migration 001 - Add 021_create_uuid_v7_function.sql: PostgreSQL uuid_generate_v7() function - Add 022_migrate_to_uuid_v7.sql: update notifications, tickets, job_payments to use v7 Seeder: - Create seeder-api/src/utils/uuid.js with uuidv7() function - Update notifications.js to use uuidv7() instead of randomUUID() Docs: - Update DATABASE.md with UUID v7 section and benefits UUID v7 benefits: - Time-ordered (sortable by creation time) - Better index performance than v4 - RFC 9562 compliant
20 lines
913 B
SQL
20 lines
913 B
SQL
-- Migration: Update UUID tables to use UUID v7
|
|
-- Description: Updates default values for notifications, tickets, job_payments to use uuid_generate_v7()
|
|
-- Requires: 021_create_uuid_v7_function.sql (must run first)
|
|
|
|
-- Update notifications table to use UUID v7
|
|
ALTER TABLE notifications ALTER COLUMN id SET DEFAULT uuid_generate_v7();
|
|
|
|
-- Update tickets table to use UUID v7
|
|
ALTER TABLE tickets ALTER COLUMN id SET DEFAULT uuid_generate_v7();
|
|
|
|
-- Update ticket_messages table to use UUID v7
|
|
ALTER TABLE ticket_messages ALTER COLUMN id SET DEFAULT uuid_generate_v7();
|
|
|
|
-- Update job_payments table to use UUID v7
|
|
ALTER TABLE job_payments ALTER COLUMN id SET DEFAULT uuid_generate_v7();
|
|
|
|
-- Comments
|
|
COMMENT ON TABLE notifications IS 'User notifications (UUID v7 IDs)';
|
|
COMMENT ON TABLE tickets IS 'Support tickets (UUID v7 IDs)';
|
|
COMMENT ON TABLE job_payments IS 'Payment records for job postings (UUID v7 IDs)';
|