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

Sepehr/step two #31

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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.xml
*.idea
*.iml
20 changes: 20 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"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": {
"start": "npx postgraphile -c todo_app -s todo_app --enhance-graphiql --watch",
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Sepehr-Sobhani/button-onboarding.git"
},
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/Sepehr-Sobhani/button-onboarding/issues"
},
"homepage": "https://github.com/Sepehr-Sobhani/button-onboarding#readme"
}
17 changes: 17 additions & 0 deletions schema/deploy/insert_seed_task.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
-- Deploy todo_app:insert_seed_task to pg
-- requires: tasks
-- requires: todo_appschema

BEGIN;

INSERT INTO
todo_app.tasks (task, completed)
VALUES
('Buy milk', false),
('Buy eggs', false),
('Buy bread', true),
('Buy coffee', false),
('Buy tea', true),
('Buy chocolate', false);

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

BEGIN;

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

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

BEGIN;

CREATE SCHEMA todo_app;

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

BEGIN;

TRUNCATE TABLE todo_app.tasks ;

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

BEGIN;

DROP TABLE IF EXISTS todo_app.tasks;

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

BEGIN;

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"]
uri = db:pg:todo_app
[engine "pg"]
target = todo_app
[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=todo_app
%uri=https://github.com/Sepehr-Sobhani/button-onboarding

todo_appschema 2022-04-06T21:11:50Z Sepehr Sobhani <[email protected]> # Add Schema for all todo app objects.
tasks [todo_appschema] 2022-04-07T18:34:52Z Sepehr Sobhani <[email protected]> # Creates table to track tasks.
insert_seed_task [tasks todo_appschema] 2022-04-07T20:37:04Z Sepehr Sobhani <[email protected]> # Create seed data for tasks table
7 changes: 7 additions & 0 deletions schema/verify/insert_seed_task.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- Verify todo_app:insert_seed_task on pg

BEGIN;

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

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

BEGIN;

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

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

BEGIN;

DO $$
BEGIN
ASSERT(SELECT pg_catalog.has_schema_privilege('todo_app', 'usage'));
END $$;


ROLLBACK;