BOD-16 Courtesy Car Schema Changes

This commit is contained in:
Patrick Fic
2020-03-30 12:06:51 -07:00
parent b7dceae83f
commit 1249fd5b2c
26 changed files with 543 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: DROP TABLE "public"."cccontract";
type: run_sql

View File

@@ -0,0 +1,33 @@
- args:
cascade: false
read_only: false
sql: CREATE EXTENSION IF NOT EXISTS pgcrypto;
type: run_sql
- args:
cascade: false
read_only: false
sql: "CREATE TABLE \"public\".\"cccontract\"(\"id\" uuid NOT NULL DEFAULT gen_random_uuid(),
\"created_at\" timestamptz NOT NULL DEFAULT now(), \"updated_at\" timestamptz
NOT NULL DEFAULT now(), \"agreementnumber\" serial NOT NULL, \"courtesycarid\"
uuid NOT NULL, \"jobid\" uuid NOT NULL, \"status\" text NOT NULL DEFAULT 'Reserved',
\"start\" date, \"scheduledreturn\" date, \"actualreturn\" date, \"kmstart\"
numeric NOT NULL, \"kmend\" numeric, \"driver_dlnumber\" text NOT NULL, \"driver_dlexpiry\"
date NOT NULL, \"driver_dlst\" text NOT NULL, \"driver_fn\" text NOT NULL, \"driver_ln\"
text NOT NULL, \"driver_addr1\" text NOT NULL, \"driver_addr2\" text, \"driver_city\"
text NOT NULL, \"driver_state\" text NOT NULL, \"driver_zip\" text NOT NULL,
\"driver_ph1\" text NOT NULL, \"driver_dob\" date NOT NULL, \"cc_num\" text,
\"cc_expiry\" text, \"cc_cardholder\" text, PRIMARY KEY (\"id\") , FOREIGN KEY
(\"courtesycarid\") REFERENCES \"public\".\"courtesycars\"(\"id\") ON UPDATE
restrict ON DELETE restrict, FOREIGN KEY (\"jobid\") REFERENCES \"public\".\"jobs\"(\"id\")
ON UPDATE restrict ON DELETE restrict);\nCREATE OR REPLACE FUNCTION \"public\".\"set_current_timestamp_updated_at\"()\nRETURNS
TRIGGER AS $$\nDECLARE\n _new record;\nBEGIN\n _new := NEW;\n _new.\"updated_at\"
= NOW();\n RETURN _new;\nEND;\n$$ LANGUAGE plpgsql;\nCREATE TRIGGER \"set_public_cccontract_updated_at\"\nBEFORE
UPDATE ON \"public\".\"cccontract\"\nFOR EACH ROW\nEXECUTE PROCEDURE \"public\".\"set_current_timestamp_updated_at\"();\nCOMMENT
ON TRIGGER \"set_public_cccontract_updated_at\" ON \"public\".\"cccontract\"
\nIS 'trigger to set value of column \"updated_at\" to current timestamp on
row update';"
type: run_sql
- args:
name: cccontract
schema: public
type: add_existing_table_or_view