Skip to content
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# dependencies
node_modules
17 changes: 17 additions & 0 deletions db/schema/deploy/insert_task.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
-- Deploy db:insert_task to pg
-- requires: tasks
-- requires: todo_app

BEGIN;

INSERT INTO
todo_app.tasks (task, completed, date_created, date_updated)
VALUES
('Clone project', TRUE, NOW(), NOW()),
('Create database', TRUE, NOW(), NOW()),
('Initialize sqitch schema', TRUE, NOW(), NOW()),
('Create dummy data', TRUE, NOW(), NOW()),
('Create Postgraphile API', FALSE, NOW(), NOW()),
('Create front end', FALSE, NOW(), NOW());

COMMIT;
16 changes: 16 additions & 0 deletions db/schema/deploy/tasks.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-- Deploy db:tasks to pg
-- requires: todo_app

BEGIN;

SET client_min_messages = 'warning';

CREATE TABLE todo_app.tasks (
id SERIAL PRIMARY KEY,
task TEXT NOT NULL,
completed BOOLEAN NOT NULL,
date_created TIMESTAMPTZ NOT NULL DEFAULT NOW(),
date_updated TIMESTAMPTZ NOT NULL DEFAULT NOW()
);

COMMIT;
7 changes: 7 additions & 0 deletions db/schema/deploy/todo_app.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- Deploy db:todo_app to pg

BEGIN;

CREATE SCHEMA todo_app;

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

BEGIN;

-- XXX Add DDLs here.

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

BEGIN;

DROP TABLE todo_app.tasks;

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

BEGIN;

DROP SCHEMA todo_app;

COMMIT;
8 changes: 8 additions & 0 deletions db/schema/sqitch.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[core]
engine = pg
plan_file = sqitch.plan
top_dir = .
[engine "pg"]
target = db:pg:todo_app
registry = sqitch
client = psql
6 changes: 6 additions & 0 deletions db/schema/sqitch.plan
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
%syntax-version=1.0.0
%project=db

todo_app 2022-03-26T15:09:15Z marcel <mlmueller@protonmail.com> # Add schema for todo app
tasks [todo_app] 2022-03-26T15:38:14Z marcel <mlmueller@protonmail.com> # Creates a table to store our todo tasks
insert_task [tasks todo_app] 2022-03-26T19:06:02Z marcel <mlmueller@protonmail.com> # Add some dummy data
8 changes: 8 additions & 0 deletions db/schema/verify/insert_task.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-- Verify db:insert_task on pg

BEGIN;

SELECT id, task, completed, date_created, date_updated
FROM todo_app.tasks;

ROLLBACK;
9 changes: 9 additions & 0 deletions db/schema/verify/tasks.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-- Verify db:tasks on pg

BEGIN;

SELECT id, task, completed, date_created, date_updated
FROM todo_app.tasks
WHERE FALSE;

ROLLBACK;
7 changes: 7 additions & 0 deletions db/schema/verify/todo_app.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- Verify db:todo_app on pg

BEGIN;

SELECT pg_catalog.has_schema_privilege('todo_app', 'usage');

ROLLBACK;
26 changes: 26 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"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",
"api": "npx postgraphile -c postgres://marcel:marcel@localhost:5432/todo_app -s todo_app --watch --enhance-graphiql",
"deploy": "cd ./db/schema && sqitch deploy",
"verify": "cd ./db/schema && sqitch verify",
"revert": "cd ./db/schema && sqitch revert"
},
"repository": {
"type": "git",
"url": "git+https://github.com/marcellmueller/button-onboarding.git"
},
"author": "Marcel Mueller",
"license": "ISC",
"bugs": {
"url": "https://github.com/marcellmueller/button-onboarding/issues"
},
"homepage": "https://github.com/marcellmueller/button-onboarding#readme",
"dependencies": {
"postgraphile": "^4.12.9"
}
}
Loading