diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b164a65 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*.xml +*.idea +*.iml diff --git a/package.json b/package.json new file mode 100644 index 0000000..68a8271 --- /dev/null +++ b/package.json @@ -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" +} diff --git a/schema/deploy/insert_seed_task.sql b/schema/deploy/insert_seed_task.sql new file mode 100644 index 0000000..6691933 --- /dev/null +++ b/schema/deploy/insert_seed_task.sql @@ -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; diff --git a/schema/deploy/tasks.sql b/schema/deploy/tasks.sql new file mode 100644 index 0000000..54362c7 --- /dev/null +++ b/schema/deploy/tasks.sql @@ -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; 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/insert_seed_task.sql b/schema/revert/insert_seed_task.sql new file mode 100644 index 0000000..3efbf32 --- /dev/null +++ b/schema/revert/insert_seed_task.sql @@ -0,0 +1,7 @@ +-- Revert todo_app:insert_seed_task from pg + +BEGIN; + +TRUNCATE TABLE todo_app.tasks ; + +COMMIT; diff --git a/schema/revert/tasks.sql b/schema/revert/tasks.sql new file mode 100644 index 0000000..7666b8e --- /dev/null +++ b/schema/revert/tasks.sql @@ -0,0 +1,7 @@ +-- Revert todo_app:tasks from pg + +BEGIN; + +DROP TABLE IF EXISTS todo_app.tasks; + +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.conf b/schema/sqitch.conf new file mode 100644 index 0000000..c3e82af --- /dev/null +++ b/schema/sqitch.conf @@ -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 diff --git a/schema/sqitch.plan b/schema/sqitch.plan new file mode 100644 index 0000000..f0bdf5a --- /dev/null +++ b/schema/sqitch.plan @@ -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 # Add Schema for all todo app objects. +tasks [todo_appschema] 2022-04-07T18:34:52Z Sepehr Sobhani # Creates table to track tasks. +insert_seed_task [tasks todo_appschema] 2022-04-07T20:37:04Z Sepehr Sobhani # Create seed data for tasks table diff --git a/schema/verify/insert_seed_task.sql b/schema/verify/insert_seed_task.sql new file mode 100644 index 0000000..e223dc0 --- /dev/null +++ b/schema/verify/insert_seed_task.sql @@ -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; diff --git a/schema/verify/tasks.sql b/schema/verify/tasks.sql new file mode 100644 index 0000000..6b60e6d --- /dev/null +++ b/schema/verify/tasks.sql @@ -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; diff --git a/schema/verify/todo_appschema.sql b/schema/verify/todo_appschema.sql new file mode 100644 index 0000000..d5cb97d --- /dev/null +++ b/schema/verify/todo_appschema.sql @@ -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;