Duration
9s
Input Tokens
1022
Output Tokens
280
Cost
$0.00
Context
Input
Create a new table where I can store how much we pay instructors each month.
Expected output
CREATE TABLE instructor_payouts ( instructor_id INT REFERENCES users(user_id), payout_month DATE, amount DECIMAL(10, 2), PRIMARY KEY (instructor_id, payout_month) );
Model output
CREATE TABLE instructor_payments (
payment_id SERIAL PRIMARY KEY,
instructor_id INT REFERENCES users(user_id),
amount DECIMAL(10, 2) NOT NULL,
payment_month DATE NOT NULL,
payment_date TIMESTAMP DEFAULT NOW(),
status TEXT CHECK (status IN ('pending', 'paid', 'failed')) DEFAULT 'pending',
notes TEXT,
CONSTRAINT fk_instructor FOREIGN KEY (instructor_id)
REFERENCES users(user_id) ON DELETE CASCADE,
CONSTRAINT instructor_is_instructor CHECK (
instructor_id IN (
SELECT user_id FROM users WHERE role = 'instructor'
)
)
);
CREATE INDEX idx_instructor_payments_month ON instructor_payments(payment_month);