From 3c5c998a07aa07a105e959b1ef7c7844babd8322 Mon Sep 17 00:00:00 2001 From: JoshLarouche Date: Tue, 21 Mar 2023 10:47:03 -0700 Subject: [PATCH 1/7] more sqitch init config --- schema/deploy/appschema.sql | 8 ++++++++ schema/revert/appschema.sql | 8 ++++++++ schema/sqitch.conf | 8 ++++++++ schema/sqitch.plan | 5 +++++ schema/verify/appschema.sql | 7 +++++++ 5 files changed, 36 insertions(+) create mode 100644 schema/deploy/appschema.sql create mode 100644 schema/revert/appschema.sql create mode 100644 schema/sqitch.conf create mode 100644 schema/sqitch.plan create mode 100644 schema/verify/appschema.sql diff --git a/schema/deploy/appschema.sql b/schema/deploy/appschema.sql new file mode 100644 index 0000000..4672130 --- /dev/null +++ b/schema/deploy/appschema.sql @@ -0,0 +1,8 @@ +-- Deploy schema:appschema to pg + +BEGIN; + +-- XXX Add DDLs here. +CREATE SCHEMA cas_onboarding; + +COMMIT; diff --git a/schema/revert/appschema.sql b/schema/revert/appschema.sql new file mode 100644 index 0000000..eefb408 --- /dev/null +++ b/schema/revert/appschema.sql @@ -0,0 +1,8 @@ +-- Revert schema:appschema from pg + +BEGIN; + +-- XXX Add DDLs here. +DROP SCHEMA cas_onboarding; + +COMMIT; diff --git a/schema/sqitch.conf b/schema/sqitch.conf new file mode 100644 index 0000000..3447459 --- /dev/null +++ b/schema/sqitch.conf @@ -0,0 +1,8 @@ +[core] + engine = pg + # plan_file = sqitch.plan + # top_dir = . +# [engine "pg"] + # target = db:pg: + # registry = sqitch + # client = psql diff --git a/schema/sqitch.plan b/schema/sqitch.plan new file mode 100644 index 0000000..b393df8 --- /dev/null +++ b/schema/sqitch.plan @@ -0,0 +1,5 @@ +%syntax-version=1.0.0 +%project=schema +%uri=https://github.com/JoshLarouche/cas-onboarding/ + +appschema 2023-03-20T22:06:14Z JoshLarouche # Add schema for all cas_onboarding objects. diff --git a/schema/verify/appschema.sql b/schema/verify/appschema.sql new file mode 100644 index 0000000..aa3c37d --- /dev/null +++ b/schema/verify/appschema.sql @@ -0,0 +1,7 @@ +-- Verify schema:appschema on pg + +BEGIN; + +-- XXX Add verifications here. + +ROLLBACK; From 06742cc92895514f69226a959af1a9b9e54cbf0b Mon Sep 17 00:00:00 2001 From: JoshLarouche Date: Wed, 22 Mar 2023 13:52:38 -0700 Subject: [PATCH 2/7] add todo schema --- schema/deploy/appschema.sql | 2 +- schema/revert/appschema.sql | 2 +- schema/sqitch.conf | 4 ++++ schema/verify/appschema.sql | 8 ++++++++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/schema/deploy/appschema.sql b/schema/deploy/appschema.sql index 4672130..fbc44ba 100644 --- a/schema/deploy/appschema.sql +++ b/schema/deploy/appschema.sql @@ -3,6 +3,6 @@ BEGIN; -- XXX Add DDLs here. -CREATE SCHEMA cas_onboarding; +CREATE SCHEMA todo; COMMIT; diff --git a/schema/revert/appschema.sql b/schema/revert/appschema.sql index eefb408..2f2a833 100644 --- a/schema/revert/appschema.sql +++ b/schema/revert/appschema.sql @@ -3,6 +3,6 @@ BEGIN; -- XXX Add DDLs here. -DROP SCHEMA cas_onboarding; +DROP SCHEMA todo; COMMIT; diff --git a/schema/sqitch.conf b/schema/sqitch.conf index 3447459..d67a57f 100644 --- a/schema/sqitch.conf +++ b/schema/sqitch.conf @@ -6,3 +6,7 @@ # target = db:pg: # registry = sqitch # client = psql +[target "todo_test"] +    uri = db:pg:todo_test +[engine "pg"] +    target = todo_test \ No newline at end of file diff --git a/schema/verify/appschema.sql b/schema/verify/appschema.sql index aa3c37d..cbf9ed7 100644 --- a/schema/verify/appschema.sql +++ b/schema/verify/appschema.sql @@ -3,5 +3,13 @@ BEGIN; -- XXX Add verifications here. +SELECT pg_catalog.has_schema_privilege('todo', 'usage'); + +SELECT 1/COUNT(*) FROM information_schema.schemata WHERE schema_name = 'todo'; + +DO $$ +BEGIN + ASSERT (SELECT has_schema_privilege('todo', 'usage')); +END $$; ROLLBACK; From d95fe4df422de92ae176b01ac22dd4e38157b7da Mon Sep 17 00:00:00 2001 From: JoshLarouche Date: Wed, 22 Mar 2023 14:07:26 -0700 Subject: [PATCH 3/7] Set default deployment target and always verify. --- schema/sqitch.conf | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/schema/sqitch.conf b/schema/sqitch.conf index d67a57f..9115383 100644 --- a/schema/sqitch.conf +++ b/schema/sqitch.conf @@ -9,4 +9,8 @@ [target "todo_test"]     uri = db:pg:todo_test [engine "pg"] -    target = todo_test \ No newline at end of file +    target = todo_test +[deploy] + verify = true +[rebase] + verify = true From efd12a2e290a66f284dd772214e6ca874ccfa45b Mon Sep 17 00:00:00 2001 From: JoshLarouche Date: Thu, 23 Mar 2023 16:33:17 -0700 Subject: [PATCH 4/7] Added todo_app schema --- schema/deploy/appschema.sql | 8 -------- schema/deploy/todo_appschema.sql | 8 ++++++++ schema/revert/appschema.sql | 8 -------- schema/revert/todo_appschema.sql | 8 ++++++++ schema/sqitch.conf | 6 +++--- schema/sqitch.plan | 2 +- schema/verify/appschema.sql | 15 --------------- schema/verify/todo_appschema.sql | 15 +++++++++++++++ 8 files changed, 35 insertions(+), 35 deletions(-) delete mode 100644 schema/deploy/appschema.sql create mode 100644 schema/deploy/todo_appschema.sql delete mode 100644 schema/revert/appschema.sql create mode 100644 schema/revert/todo_appschema.sql delete mode 100644 schema/verify/appschema.sql create mode 100644 schema/verify/todo_appschema.sql diff --git a/schema/deploy/appschema.sql b/schema/deploy/appschema.sql deleted file mode 100644 index fbc44ba..0000000 --- a/schema/deploy/appschema.sql +++ /dev/null @@ -1,8 +0,0 @@ --- Deploy schema:appschema to pg - -BEGIN; - --- XXX Add DDLs here. -CREATE SCHEMA todo; - -COMMIT; diff --git a/schema/deploy/todo_appschema.sql b/schema/deploy/todo_appschema.sql new file mode 100644 index 0000000..c8e9ec0 --- /dev/null +++ b/schema/deploy/todo_appschema.sql @@ -0,0 +1,8 @@ +-- Deploy schema:todo_appschema to pg + +BEGIN; + +-- XXX Add DDLs here. +CREATE SCHEMA todo_app; + +COMMIT; diff --git a/schema/revert/appschema.sql b/schema/revert/appschema.sql deleted file mode 100644 index 2f2a833..0000000 --- a/schema/revert/appschema.sql +++ /dev/null @@ -1,8 +0,0 @@ --- Revert schema:appschema from pg - -BEGIN; - --- XXX Add DDLs here. -DROP SCHEMA todo; - -COMMIT; diff --git a/schema/revert/todo_appschema.sql b/schema/revert/todo_appschema.sql new file mode 100644 index 0000000..b2c001b --- /dev/null +++ b/schema/revert/todo_appschema.sql @@ -0,0 +1,8 @@ +-- Revert schema:todo_appschema from pg + +BEGIN; + +-- XXX Add DDLs here. +DROP SCHEMA todo_app; + +COMMIT; diff --git a/schema/sqitch.conf b/schema/sqitch.conf index 9115383..64fda6c 100644 --- a/schema/sqitch.conf +++ b/schema/sqitch.conf @@ -6,10 +6,10 @@ # target = db:pg: # registry = sqitch # client = psql -[target "todo_test"] -    uri = db:pg:todo_test +[target "todo_app_test"] +    uri = db:pg:todo_app_test [engine "pg"] -    target = todo_test +    target = todo_app_test [deploy] verify = true [rebase] diff --git a/schema/sqitch.plan b/schema/sqitch.plan index b393df8..6868b79 100644 --- a/schema/sqitch.plan +++ b/schema/sqitch.plan @@ -2,4 +2,4 @@ %project=schema %uri=https://github.com/JoshLarouche/cas-onboarding/ -appschema 2023-03-20T22:06:14Z JoshLarouche # Add schema for all cas_onboarding objects. +todo_appschema 2023-03-23T16:20:40Z JoshLarouche # Add schema for all todo objects. diff --git a/schema/verify/appschema.sql b/schema/verify/appschema.sql deleted file mode 100644 index cbf9ed7..0000000 --- a/schema/verify/appschema.sql +++ /dev/null @@ -1,15 +0,0 @@ --- Verify schema:appschema on pg - -BEGIN; - --- XXX Add verifications here. -SELECT pg_catalog.has_schema_privilege('todo', 'usage'); - -SELECT 1/COUNT(*) FROM information_schema.schemata WHERE schema_name = 'todo'; - -DO $$ -BEGIN - ASSERT (SELECT has_schema_privilege('todo', 'usage')); -END $$; - -ROLLBACK; diff --git a/schema/verify/todo_appschema.sql b/schema/verify/todo_appschema.sql new file mode 100644 index 0000000..be68c24 --- /dev/null +++ b/schema/verify/todo_appschema.sql @@ -0,0 +1,15 @@ +-- Verify schema:todo_appschema on pg + +BEGIN; + +-- XXX Add verifications here. +SELECT pg_catalog.has_schema_privilege('todo_app', 'usage'); + +SELECT 1/COUNT(*) FROM information_schema.schemata WHERE schema_name = 'todo_app'; + +DO $$ +BEGIN + ASSERT (SELECT has_schema_privilege('todo_app', 'usage')); +END $$; + +ROLLBACK; From bd5a1a2065d415936c61d3a98d5d3a16757729f8 Mon Sep 17 00:00:00 2001 From: JoshLarouche Date: Fri, 24 Mar 2023 08:18:58 -0700 Subject: [PATCH 5/7] Set default deployment target and always verify. --- schema/sqitch.conf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/schema/sqitch.conf b/schema/sqitch.conf index 64fda6c..61e3aff 100644 --- a/schema/sqitch.conf +++ b/schema/sqitch.conf @@ -6,10 +6,10 @@ # target = db:pg: # registry = sqitch # client = psql -[target "todo_app_test"] -    uri = db:pg:todo_app_test +[target "todo_app_db"] +    uri = db:pg:todo_app_db [engine "pg"] -    target = todo_app_test +    target = todo_app_db [deploy] verify = true [rebase] From 0c1df2fa58a29e05f777586eea6b261a7b11d263 Mon Sep 17 00:00:00 2001 From: JoshLarouche Date: Fri, 24 Mar 2023 08:49:59 -0700 Subject: [PATCH 6/7] Add tasks table. --- schema/deploy/tasks.sql | 16 ++++++++++++++++ schema/revert/tasks.sql | 8 ++++++++ schema/sqitch.plan | 1 + schema/verify/tasks.sql | 10 ++++++++++ 4 files changed, 35 insertions(+) create mode 100644 schema/deploy/tasks.sql create mode 100644 schema/revert/tasks.sql create mode 100644 schema/verify/tasks.sql diff --git a/schema/deploy/tasks.sql b/schema/deploy/tasks.sql new file mode 100644 index 0000000..b8e37e3 --- /dev/null +++ b/schema/deploy/tasks.sql @@ -0,0 +1,16 @@ +-- Deploy schema:tasks to pg +-- requires: todo_appschema + +BEGIN; + +SET client_min_messages = 'warning'; + +CREATE TABLE todo_app.tasks ( + id INTEGER PRIMARY KEY, + task TEXT NOT NULL, + completed BOOLEAN NOT NULL DEFAULT FALSE, + date_created TIMESTAMPTZ NOT NULL DEFAULT NOW(), + date_updated TIMESTAMPTZ NOT NULL DEFAULT NOW() +); + +COMMIT; diff --git a/schema/revert/tasks.sql b/schema/revert/tasks.sql new file mode 100644 index 0000000..d8e855c --- /dev/null +++ b/schema/revert/tasks.sql @@ -0,0 +1,8 @@ +-- Revert schema:todo from pg + +BEGIN; + +-- XXX Add DDLs here. +DROP TABLE todo_app.tasks; + +COMMIT; diff --git a/schema/sqitch.plan b/schema/sqitch.plan index 6868b79..c20d282 100644 --- a/schema/sqitch.plan +++ b/schema/sqitch.plan @@ -3,3 +3,4 @@ %uri=https://github.com/JoshLarouche/cas-onboarding/ todo_appschema 2023-03-23T16:20:40Z JoshLarouche # Add schema for all todo objects. +tasks [todo_appschema] 2023-03-24T15:21:51Z JoshLarouche # Creates table to track our tasks. diff --git a/schema/verify/tasks.sql b/schema/verify/tasks.sql new file mode 100644 index 0000000..550f9d1 --- /dev/null +++ b/schema/verify/tasks.sql @@ -0,0 +1,10 @@ +-- Verify schema:todo on pg + +BEGIN; + +-- XXX Add verifications here. +SELECT id, task, completed, date_created, date_updated + FROM todo_app.tasks + WHERE FALSE; + +ROLLBACK; From 256b628400735bd31f29a43cf11147c04824e027 Mon Sep 17 00:00:00 2001 From: JoshLarouche Date: Fri, 24 Mar 2023 09:13:07 -0700 Subject: [PATCH 7/7] Added seed data to insert into tasks table. --- schema/deploy/insert_seed_data.sql | 19 +++++++++++++++++++ schema/revert/insert_seed_data.sql | 8 ++++++++ schema/sqitch.plan | 1 + schema/verify/insert_seed_data.sql | 9 +++++++++ schema/verify/tasks.sql | 2 +- 5 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 schema/deploy/insert_seed_data.sql create mode 100644 schema/revert/insert_seed_data.sql create mode 100644 schema/verify/insert_seed_data.sql diff --git a/schema/deploy/insert_seed_data.sql b/schema/deploy/insert_seed_data.sql new file mode 100644 index 0000000..1e3a439 --- /dev/null +++ b/schema/deploy/insert_seed_data.sql @@ -0,0 +1,19 @@ +-- Deploy schema:insert_seed_data to pg +-- requires: todo_appschema +-- requires: tasks + +BEGIN; + +-- XXX Add DDLs here. +INSERT INTO + todo_app.tasks (id, task, completed) + VALUES + (1, 'Make bed', false), + (2, 'Shower', false), + (3, 'Write todo list', true), + (4, 'Learn to hack', false), + (5, 'Lunch with Julia', false), + (6, 'Buy groceries', false), + (7, 'Feed dog', true); + +COMMIT; diff --git a/schema/revert/insert_seed_data.sql b/schema/revert/insert_seed_data.sql new file mode 100644 index 0000000..7bd8f21 --- /dev/null +++ b/schema/revert/insert_seed_data.sql @@ -0,0 +1,8 @@ +-- Revert schema:insert_seed_data from pg + +BEGIN; + +-- XXX Add DDLs here. +TRUNCATE TABLE todo_app.tasks; + +COMMIT; diff --git a/schema/sqitch.plan b/schema/sqitch.plan index c20d282..644d698 100644 --- a/schema/sqitch.plan +++ b/schema/sqitch.plan @@ -4,3 +4,4 @@ todo_appschema 2023-03-23T16:20:40Z JoshLarouche # Add schema for all todo objects. tasks [todo_appschema] 2023-03-24T15:21:51Z JoshLarouche # Creates table to track our tasks. +insert_seed_data [todo_appschema] 2023-03-24T15:53:29Z JoshLarouche # Inserts seed data into tasks table. diff --git a/schema/verify/insert_seed_data.sql b/schema/verify/insert_seed_data.sql new file mode 100644 index 0000000..9282601 --- /dev/null +++ b/schema/verify/insert_seed_data.sql @@ -0,0 +1,9 @@ +-- Verify schema:insert_seed_data on pg + +BEGIN; + +-- XXX Add verifications here. +SELECT id, task, completed, date_created, date_updated + FROM todo_app.tasks; + +ROLLBACK; diff --git a/schema/verify/tasks.sql b/schema/verify/tasks.sql index 550f9d1..dec50bc 100644 --- a/schema/verify/tasks.sql +++ b/schema/verify/tasks.sql @@ -4,7 +4,7 @@ BEGIN; -- XXX Add verifications here. SELECT id, task, completed, date_created, date_updated - FROM todo_app.tasks + FROM todo_app.tasks WHERE FALSE; ROLLBACK;