From 267eb9a2f2dd818d753b65faccd7dd69fb3abaa2 Mon Sep 17 00:00:00 2001 From: Brianna Cerkiewicz Date: Wed, 23 Feb 2022 14:43:00 -0800 Subject: [PATCH 1/9] initialize sqitch configuration --- schema/sqitch.conf | 8 ++++++++ schema/sqitch.plan | 3 +++ 2 files changed, 11 insertions(+) create mode 100644 schema/sqitch.conf create mode 100644 schema/sqitch.plan diff --git a/schema/sqitch.conf b/schema/sqitch.conf new file mode 100644 index 0000000..b3d1ddc --- /dev/null +++ b/schema/sqitch.conf @@ -0,0 +1,8 @@ +[core] + engine = pg + # plan_file = sqitch.plan + # top_dir = . +[engine "pg"] + target = todo_app +[target "todo_app"] + uri = db:pg://localhost/todo_app \ No newline at end of file diff --git a/schema/sqitch.plan b/schema/sqitch.plan new file mode 100644 index 0000000..308adb8 --- /dev/null +++ b/schema/sqitch.plan @@ -0,0 +1,3 @@ +%syntax-version=1.0.0 +%project=todo_app + From e6f064be7768e410fab694f7fba16d18d680d58a Mon Sep 17 00:00:00 2001 From: Brianna Cerkiewicz Date: Wed, 23 Feb 2022 14:47:26 -0800 Subject: [PATCH 2/9] add todo_app schema --- schema/deploy/todo_appschema.sql | 7 +++++++ schema/revert/todo_appschema.sql | 7 +++++++ schema/sqitch.plan | 1 + schema/verify/todo_appschema.sql | 7 +++++++ 4 files changed, 22 insertions(+) create mode 100644 schema/deploy/todo_appschema.sql create mode 100644 schema/revert/todo_appschema.sql create mode 100644 schema/verify/todo_appschema.sql diff --git a/schema/deploy/todo_appschema.sql b/schema/deploy/todo_appschema.sql new file mode 100644 index 0000000..916a76d --- /dev/null +++ b/schema/deploy/todo_appschema.sql @@ -0,0 +1,7 @@ +-- Deploy todo_app:todo_appschema to pg + +BEGIN; + +CREATE SCHEMA todo_app; + +COMMIT; diff --git a/schema/revert/todo_appschema.sql b/schema/revert/todo_appschema.sql new file mode 100644 index 0000000..bbfa1b0 --- /dev/null +++ b/schema/revert/todo_appschema.sql @@ -0,0 +1,7 @@ +-- Revert todo_app:todo_appschema from pg + +BEGIN; + +DROP SCHEMA todo_app; + +COMMIT; diff --git a/schema/sqitch.plan b/schema/sqitch.plan index 308adb8..5735438 100644 --- a/schema/sqitch.plan +++ b/schema/sqitch.plan @@ -1,3 +1,4 @@ %syntax-version=1.0.0 %project=todo_app +todo_appschema 2022-02-23T22:43:21Z Brianna Cerkiewicz # Add schema for all todo objects. diff --git a/schema/verify/todo_appschema.sql b/schema/verify/todo_appschema.sql new file mode 100644 index 0000000..770e07b --- /dev/null +++ b/schema/verify/todo_appschema.sql @@ -0,0 +1,7 @@ +-- Verify todo_app:todo_appschema on pg + +BEGIN; + +SELECT pg_catalog.has_schema_privilege('todo_app', 'usage'); + +ROLLBACK; From c34caf41197fae01e925853ce733db93bf623c04 Mon Sep 17 00:00:00 2001 From: Brianna Cerkiewicz Date: Wed, 23 Feb 2022 14:53:53 -0800 Subject: [PATCH 3/9] add todos table --- schema/deploy/todos.sql | 16 ++++++++++++++++ schema/revert/todos.sql | 7 +++++++ schema/sqitch.plan | 1 + schema/verify/todos.sql | 9 +++++++++ 4 files changed, 33 insertions(+) create mode 100644 schema/deploy/todos.sql create mode 100644 schema/revert/todos.sql create mode 100644 schema/verify/todos.sql diff --git a/schema/deploy/todos.sql b/schema/deploy/todos.sql new file mode 100644 index 0000000..1c01392 --- /dev/null +++ b/schema/deploy/todos.sql @@ -0,0 +1,16 @@ +-- Deploy todo_app:todos to pg +-- requires: todo_appschema + +BEGIN; + +SET client_min_messages = 'warning'; + +CREATE TABLE todo_app.todos ( + id integer primary key generated always as identity, + task TEXT NOT NULL, + completed BOOLEAN NOT NULL DEFAULT FALSE, + date_created TIMESTAMPTZ NOT NULL DEFAULT NOW(), + date_updated TIMESTAMPTZ NOT NULL +); + +COMMIT; diff --git a/schema/revert/todos.sql b/schema/revert/todos.sql new file mode 100644 index 0000000..8e1cc5c --- /dev/null +++ b/schema/revert/todos.sql @@ -0,0 +1,7 @@ +-- Revert todo_app:todos from pg + +BEGIN; + +DROP TABLE todo_app.todos; + +COMMIT; diff --git a/schema/sqitch.plan b/schema/sqitch.plan index 5735438..e3b6a04 100644 --- a/schema/sqitch.plan +++ b/schema/sqitch.plan @@ -2,3 +2,4 @@ %project=todo_app todo_appschema 2022-02-23T22:43:21Z Brianna Cerkiewicz # Add schema for all todo objects. +todos [todo_appschema] 2022-02-23T22:48:12Z Brianna Cerkiewicz # Create table to hold todos. diff --git a/schema/verify/todos.sql b/schema/verify/todos.sql new file mode 100644 index 0000000..cca145f --- /dev/null +++ b/schema/verify/todos.sql @@ -0,0 +1,9 @@ +-- Verify todo_app:todos on pg + +BEGIN; + +SELECT id, task, completed, date_created, date_updated + FROM todo_app.todos + WHERE FALSE; + +ROLLBACK; From 9576df272413e2e3da1a2b69ca421e0945ceb6f9 Mon Sep 17 00:00:00 2001 From: Brianna Cerkiewicz Date: Wed, 23 Feb 2022 15:09:26 -0800 Subject: [PATCH 4/9] change SQL to lowercase --- schema/deploy/todo_appschema.sql | 2 +- schema/deploy/todos.sql | 12 ++++++------ schema/revert/todo_appschema.sql | 2 +- schema/revert/todos.sql | 2 +- schema/verify/todo_appschema.sql | 2 +- schema/verify/todos.sql | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/schema/deploy/todo_appschema.sql b/schema/deploy/todo_appschema.sql index 916a76d..f663fc1 100644 --- a/schema/deploy/todo_appschema.sql +++ b/schema/deploy/todo_appschema.sql @@ -2,6 +2,6 @@ BEGIN; -CREATE SCHEMA todo_app; +create schema todo_app; COMMIT; diff --git a/schema/deploy/todos.sql b/schema/deploy/todos.sql index 1c01392..f2c3f07 100644 --- a/schema/deploy/todos.sql +++ b/schema/deploy/todos.sql @@ -3,14 +3,14 @@ BEGIN; -SET client_min_messages = 'warning'; +set client_min_messages = 'warning'; -CREATE TABLE todo_app.todos ( +create table todo_app.todos ( id integer primary key generated always as identity, - task TEXT NOT NULL, - completed BOOLEAN NOT NULL DEFAULT FALSE, - date_created TIMESTAMPTZ NOT NULL DEFAULT NOW(), - date_updated TIMESTAMPTZ NOT NULL + task text not null, + completed boolean not null default false, + date_created timestamptz not null default now(), + date_updated timestamptz not null ); COMMIT; diff --git a/schema/revert/todo_appschema.sql b/schema/revert/todo_appschema.sql index bbfa1b0..20b6179 100644 --- a/schema/revert/todo_appschema.sql +++ b/schema/revert/todo_appschema.sql @@ -2,6 +2,6 @@ BEGIN; -DROP SCHEMA todo_app; +drop schema todo_app; COMMIT; diff --git a/schema/revert/todos.sql b/schema/revert/todos.sql index 8e1cc5c..9cf172f 100644 --- a/schema/revert/todos.sql +++ b/schema/revert/todos.sql @@ -2,6 +2,6 @@ BEGIN; -DROP TABLE todo_app.todos; +drop table todo_app.todos; COMMIT; diff --git a/schema/verify/todo_appschema.sql b/schema/verify/todo_appschema.sql index 770e07b..253a3ed 100644 --- a/schema/verify/todo_appschema.sql +++ b/schema/verify/todo_appschema.sql @@ -2,6 +2,6 @@ BEGIN; -SELECT pg_catalog.has_schema_privilege('todo_app', 'usage'); +select pg_catalog.has_schema_privilege('todo_app', 'usage'); ROLLBACK; diff --git a/schema/verify/todos.sql b/schema/verify/todos.sql index cca145f..ed73aa2 100644 --- a/schema/verify/todos.sql +++ b/schema/verify/todos.sql @@ -2,7 +2,7 @@ BEGIN; -SELECT id, task, completed, date_created, date_updated +select id, task, completed, date_created, date_updated FROM todo_app.todos WHERE FALSE; From 20ead7d6e9f9f0a84932bff65f5ffa2ad82ad80d Mon Sep 17 00:00:00 2001 From: Brianna Cerkiewicz Date: Wed, 23 Feb 2022 16:21:47 -0800 Subject: [PATCH 5/9] add insert todo function --- schema/deploy/insert_todo.sql | 14 ++++++++++++++ schema/revert/insert_todo.sql | 7 +++++++ schema/sqitch.plan | 1 + schema/verify/insert_todo.sql | 7 +++++++ 4 files changed, 29 insertions(+) create mode 100644 schema/deploy/insert_todo.sql create mode 100644 schema/revert/insert_todo.sql create mode 100644 schema/verify/insert_todo.sql diff --git a/schema/deploy/insert_todo.sql b/schema/deploy/insert_todo.sql new file mode 100644 index 0000000..ba4c750 --- /dev/null +++ b/schema/deploy/insert_todo.sql @@ -0,0 +1,14 @@ +-- Deploy todo_app:insert_todo to pg +-- requires: todos +-- requires: todo_appschema + +BEGIN; + +create or replace function todo_app.insert_todo( + task text, + completed boolean +) returns void language sql security definer as $$ + insert into todo_app.todos(task, completed) values($1, $2); +$$; + +COMMIT; diff --git a/schema/revert/insert_todo.sql b/schema/revert/insert_todo.sql new file mode 100644 index 0000000..9b5cf85 --- /dev/null +++ b/schema/revert/insert_todo.sql @@ -0,0 +1,7 @@ +-- Revert todo_app:insert_todo from pg + +BEGIN; + +drop function todo_app.insert_todo(text, boolean); + +COMMIT; diff --git a/schema/sqitch.plan b/schema/sqitch.plan index e3b6a04..3f73a8c 100644 --- a/schema/sqitch.plan +++ b/schema/sqitch.plan @@ -3,3 +3,4 @@ todo_appschema 2022-02-23T22:43:21Z Brianna Cerkiewicz # Add schema for all todo objects. todos [todo_appschema] 2022-02-23T22:48:12Z Brianna Cerkiewicz # Create table to hold todos. +insert_todo [todos todo_appschema] 2022-02-23T23:18:41Z Brianna Cerkiewicz # Creates a function to insert a todo. diff --git a/schema/verify/insert_todo.sql b/schema/verify/insert_todo.sql new file mode 100644 index 0000000..9b7a74d --- /dev/null +++ b/schema/verify/insert_todo.sql @@ -0,0 +1,7 @@ +-- Verify todo_app:insert_todo on pg + +BEGIN; + +select has_function_privilege('todo_app.insert_todo(text, boolean)', 'execute'); + +ROLLBACK; From 1a6397745cea77f4829786e89f6a576cbe2f4dd0 Mon Sep 17 00:00:00 2001 From: Brianna Cerkiewicz Date: Fri, 25 Feb 2022 13:39:21 -0800 Subject: [PATCH 6/9] give date_updated in todos table a default value --- schema/deploy/todos.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schema/deploy/todos.sql b/schema/deploy/todos.sql index f2c3f07..ea41352 100644 --- a/schema/deploy/todos.sql +++ b/schema/deploy/todos.sql @@ -10,7 +10,7 @@ create table todo_app.todos ( task text not null, completed boolean not null default false, date_created timestamptz not null default now(), - date_updated timestamptz not null + date_updated timestamptz not null default now() ); COMMIT; From ad343d06bcc7cbf632fc1245008d2a767270faa8 Mon Sep 17 00:00:00 2001 From: Brianna Cerkiewicz Date: Fri, 25 Feb 2022 13:39:32 -0800 Subject: [PATCH 7/9] create seed data --- schema/deploy/seed_todo.sql | 11 +++++++++++ schema/revert/seed_todo.sql | 7 +++++++ schema/sqitch.plan | 1 + schema/verify/seed_todo.sql | 14 ++++++++++++++ 4 files changed, 33 insertions(+) create mode 100644 schema/deploy/seed_todo.sql create mode 100644 schema/revert/seed_todo.sql create mode 100644 schema/verify/seed_todo.sql diff --git a/schema/deploy/seed_todo.sql b/schema/deploy/seed_todo.sql new file mode 100644 index 0000000..70fe132 --- /dev/null +++ b/schema/deploy/seed_todo.sql @@ -0,0 +1,11 @@ +-- Deploy todo_app:seed_todo to pg +-- requires: insert_todo +-- requires: todos +-- requires: todo_appschema + +BEGIN; + +select todo_app.insert_todo('task not done', false); +select todo_app.insert_todo('task done', true); + +COMMIT; diff --git a/schema/revert/seed_todo.sql b/schema/revert/seed_todo.sql new file mode 100644 index 0000000..002f7cc --- /dev/null +++ b/schema/revert/seed_todo.sql @@ -0,0 +1,7 @@ +-- Revert todo_app:seed_todo from pg + +BEGIN; + +delete from todo_app.todos; + +COMMIT; diff --git a/schema/sqitch.plan b/schema/sqitch.plan index 3f73a8c..ae8ccb7 100644 --- a/schema/sqitch.plan +++ b/schema/sqitch.plan @@ -4,3 +4,4 @@ todo_appschema 2022-02-23T22:43:21Z Brianna Cerkiewicz # Add schema for all todo objects. todos [todo_appschema] 2022-02-23T22:48:12Z Brianna Cerkiewicz # Create table to hold todos. insert_todo [todos todo_appschema] 2022-02-23T23:18:41Z Brianna Cerkiewicz # Creates a function to insert a todo. +seed_todo [insert_todo todos todo_appschema] 2022-02-24T00:23:11Z Brianna Cerkiewicz # Creates seed todos. diff --git a/schema/verify/seed_todo.sql b/schema/verify/seed_todo.sql new file mode 100644 index 0000000..00d9d7d --- /dev/null +++ b/schema/verify/seed_todo.sql @@ -0,0 +1,14 @@ +-- Verify todo_app:seed_todo on pg + + +BEGIN; +do $$ +declare +count integer; + +BEGIN +count := (select count(id) from todo_app.todos); +assert count = 2; +end $$ + +ROLLBACK; From a79b5dfa79c30b8f9f4fc3332818cf025b9b8afd Mon Sep 17 00:00:00 2001 From: Brianna Cerkiewicz Date: Fri, 25 Feb 2022 15:50:53 -0800 Subject: [PATCH 8/9] add username and email to sqitch config --- schema/sqitch.conf | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/schema/sqitch.conf b/schema/sqitch.conf index b3d1ddc..aaca578 100644 --- a/schema/sqitch.conf +++ b/schema/sqitch.conf @@ -1,8 +1,11 @@ [core] - engine = pg - # plan_file = sqitch.plan - # top_dir = . + engine = pg + # plan_file = sqitch.plan + # top_dir = . [engine "pg"] - target = todo_app + target = todo_app [target "todo_app"] - uri = db:pg://localhost/todo_app \ No newline at end of file + uri = db:pg://localhost/todo_app +[user] + name = Brianna Cerkiewicz + email = brianna@button.is \ No newline at end of file From bfb218f976ecb8caed5712fda875b6644b52b5c8 Mon Sep 17 00:00:00 2001 From: Brianna Cerkiewicz Date: Mon, 28 Feb 2022 10:09:14 -0800 Subject: [PATCH 9/9] install postgraphile --- .gitignore | 1 + package.json | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 .gitignore create mode 100644 package.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b512c09 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..6ce28ac --- /dev/null +++ b/package.json @@ -0,0 +1,19 @@ +{ + "name": "button-onboarding", + "version": "1.0.0", + "description": "A guide to help developers onboard to the Button stack by building a simple todo app.", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/BCerki/button-onboarding.git" + }, + "author": "", + "license": "ISC", + "bugs": { + "url": "https://github.com/BCerki/button-onboarding/issues" + }, + "homepage": "https://github.com/BCerki/button-onboarding#readme" +}