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"."courtesycars";
type: run_sql

View File

@@ -0,0 +1,31 @@
- 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\".\"courtesycars\"(\"id\" uuid NOT NULL DEFAULT gen_random_uuid(),
\"created_at\" timestamptz NOT NULL DEFAULT now(), \"updated_at\" timestamptz
NOT NULL DEFAULT now(), \"bodyshopid\" uuid NOT NULL, \"make\" text NOT NULL,
\"model\" text NOT NULL, \"year\" text NOT NULL, \"plate\" text NOT NULL, \"color\"
text NOT NULL, \"vin\" text NOT NULL, \"fleetnumber\" text, \"purchasedate\"
date, \"servicestartdate\" date, \"serviceenddate\" date, \"leaseenddate\" date,
\"status\" text NOT NULL DEFAULT 'Available', \"NextServiceKm\" numeric NOT
NULL DEFAULT 0, \"NextServiceDate\" date, \"Damage\" text, \"Notes\" text, \"fuel\"
numeric NOT NULL DEFAULT 1, \"registrationexpires\" date, \"insuranceexpires\"
date, \"dailycost\" numeric NOT NULL DEFAULT 0, PRIMARY KEY (\"id\") , FOREIGN
KEY (\"bodyshopid\") REFERENCES \"public\".\"bodyshops\"(\"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_courtesycars_updated_at\"\nBEFORE
UPDATE ON \"public\".\"courtesycars\"\nFOR EACH ROW\nEXECUTE PROCEDURE \"public\".\"set_current_timestamp_updated_at\"();\nCOMMENT
ON TRIGGER \"set_public_courtesycars_updated_at\" ON \"public\".\"courtesycars\"
\nIS 'trigger to set value of column \"updated_at\" to current timestamp on
row update';"
type: run_sql
- args:
name: courtesycars
schema: public
type: add_existing_table_or_view