fix(migrations): change job_payments FK types from UUID to INT

- job_id changed from UUID to INT to match jobs.id SERIAL
- user_id changed from UUID to INT to match users.id SERIAL
- Added user_id FK to users table
This commit is contained in:
Tiago Yamamoto 2025-12-24 10:49:33 -03:00
parent 2fb81a6d1a
commit 254d7c3216

View file

@ -3,8 +3,8 @@
CREATE TABLE IF NOT EXISTS job_payments (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
job_id UUID NOT NULL,
user_id UUID,
job_id INT NOT NULL,
user_id INT,
-- Stripe
stripe_session_id VARCHAR(255),
@ -39,8 +39,9 @@ CREATE TABLE IF NOT EXISTS job_payments (
paid_at TIMESTAMP,
expires_at TIMESTAMP,
-- Foreign key (UUID to match jobs table)
FOREIGN KEY (job_id) REFERENCES jobs(id) ON DELETE CASCADE
-- Foreign key (INT to match jobs.id SERIAL)
FOREIGN KEY (job_id) REFERENCES jobs(id) ON DELETE CASCADE,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE SET NULL
);
-- Indexes