fix: reorder uuid_generate_v7 migration to run before tables that use it
- Rename 021_create_uuid_v7_function.sql to 009_create_uuid_v7_function.sql - Add CREATE EXTENSION IF NOT EXISTS pgcrypto for gen_random_bytes() - Remove obsolete 022_migrate_to_uuid_v7.sql (already handled by table def) This fixes the error where migration 017 tried to use uuid_generate_v7() before it was created.
This commit is contained in:
parent
246c55b0f5
commit
5f3430bd98
2 changed files with 3 additions and 20 deletions
|
|
@ -3,6 +3,9 @@
|
||||||
-- UUID v7 format: tttttttt-tttt-7xxx-yxxx-xxxxxxxxxxxx
|
-- UUID v7 format: tttttttt-tttt-7xxx-yxxx-xxxxxxxxxxxx
|
||||||
-- Where: t = timestamp, 7 = version, y = variant, x = random
|
-- Where: t = timestamp, 7 = version, y = variant, x = random
|
||||||
|
|
||||||
|
-- Enable pgcrypto extension for gen_random_bytes()
|
||||||
|
CREATE EXTENSION IF NOT EXISTS pgcrypto;
|
||||||
|
|
||||||
-- Create or replace the uuid_generate_v7 function
|
-- Create or replace the uuid_generate_v7 function
|
||||||
CREATE OR REPLACE FUNCTION uuid_generate_v7()
|
CREATE OR REPLACE FUNCTION uuid_generate_v7()
|
||||||
RETURNS uuid AS $$
|
RETURNS uuid AS $$
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
-- 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)';
|
|
||||||
Loading…
Reference in a new issue