From 05b6e730fa81a4ec02fbf361967896f0c9f3a2d4 Mon Sep 17 00:00:00 2001 From: Masaya Tojo Date: Mon, 13 Mar 2023 00:11:31 +0900 Subject: Add article_id column to transactions table. --- deploy/transactions.sql | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'deploy/transactions.sql') diff --git a/deploy/transactions.sql b/deploy/transactions.sql index e37b276..0572a23 100644 --- a/deploy/transactions.sql +++ b/deploy/transactions.sql @@ -1,15 +1,12 @@ -- Deploy kakeibo:transactions to pg -- requires: schema +-- requires: articles BEGIN; -CREATE TABLE kakeibo.transactions ( - id SERIAL PRIMARY KEY, - type_code INTEGER, - date DATE NOT NULL, - note TEXT, - created_at TIMESTAMP NOT NULL DEFAULT NOW(), - updated_at TIMESTAMP NOT NULL DEFAULT NOW() -); +ALTER TABLE kakeibo.transactions + ADD COLUMN article_id INTEGER, + ADD CONSTRAINT transactions_article_id_fkey + FOREIGN KEY (article_id) REFERENCES kakeibo.articles (id); COMMIT; -- cgit v1.2.3