Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Josh/step1 #9

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions schema/deploy/insert_seed_data.sql
Original file line number Diff line number Diff line change
@@ -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;
16 changes: 16 additions & 0 deletions schema/deploy/tasks.sql
Original file line number Diff line number Diff line change
@@ -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;
8 changes: 8 additions & 0 deletions schema/deploy/todo_appschema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-- Deploy schema:todo_appschema to pg

BEGIN;

-- XXX Add DDLs here.
CREATE SCHEMA todo_app;

COMMIT;
8 changes: 8 additions & 0 deletions schema/revert/insert_seed_data.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-- Revert schema:insert_seed_data from pg

BEGIN;

-- XXX Add DDLs here.
TRUNCATE TABLE todo_app.tasks;

COMMIT;
8 changes: 8 additions & 0 deletions schema/revert/tasks.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-- Revert schema:todo from pg

BEGIN;

-- XXX Add DDLs here.
DROP TABLE todo_app.tasks;

COMMIT;
8 changes: 8 additions & 0 deletions schema/revert/todo_appschema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-- Revert schema:todo_appschema from pg

BEGIN;

-- XXX Add DDLs here.
DROP SCHEMA todo_app;

COMMIT;
16 changes: 16 additions & 0 deletions schema/sqitch.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[core]
engine = pg
# plan_file = sqitch.plan
# top_dir = .
# [engine "pg"]
# target = db:pg:
# registry = sqitch
# client = psql
[target "todo_app_db"]
    uri = db:pg:todo_app_db
[engine "pg"]
    target = todo_app_db
[deploy]
verify = true
[rebase]
verify = true
7 changes: 7 additions & 0 deletions schema/sqitch.plan
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
%syntax-version=1.0.0
%project=schema
%uri=https://github.com/JoshLarouche/cas-onboarding/

todo_appschema 2023-03-23T16:20:40Z JoshLarouche <joshua.t.larouche@gmail.com> # Add schema for all todo objects.
tasks [todo_appschema] 2023-03-24T15:21:51Z JoshLarouche <joshua.t.larouche@gmail.com> # Creates table to track our tasks.
insert_seed_data [todo_appschema] 2023-03-24T15:53:29Z JoshLarouche <joshua.t.larouche@gmail.com> # Inserts seed data into tasks table.
9 changes: 9 additions & 0 deletions schema/verify/insert_seed_data.sql
Original file line number Diff line number Diff line change
@@ -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;
10 changes: 10 additions & 0 deletions schema/verify/tasks.sql
Original file line number Diff line number Diff line change
@@ -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;
15 changes: 15 additions & 0 deletions schema/verify/todo_appschema.sql
Original file line number Diff line number Diff line change
@@ -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;