-
Notifications
You must be signed in to change notification settings - Fork 11
Naomi/step 1 #13
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
Draft
naomiaro
wants to merge
7
commits into
button-inc:main
Choose a base branch
from
naomiaro:naomi/step-1
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Naomi/step 1 #13
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
4ea47bd
Add first sqitch stuff
4c85dbc
update sqitch conf
1e3bc70
create appschema for todo_app
42cc597
create todos sqitch files
7181feb
create an insert todo function
87aaa76
Add seed data
71d3c52
Add more seeds
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| schema/sqitch.plan merge=union |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| .DS_Store |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| -- Deploy onboarding:appschema to pg | ||
|
|
||
| BEGIN; | ||
|
|
||
| CREATE SCHEMA todo_app; | ||
|
|
||
| COMMIT; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| -- Deploy onboarding:insert_todo to pg | ||
| -- requires: todos | ||
| -- requires: 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| -- Deploy onboarding:seed_todo to pg | ||
| -- requires: insert_todo | ||
| -- requires: todos | ||
| -- requires: appschema | ||
|
|
||
| BEGIN; | ||
|
|
||
| DO $$ | ||
| BEGIN | ||
| PERFORM todo_app.insert_todo('Task 1', false); | ||
| PERFORM todo_app.insert_todo('Task 2', false); | ||
| PERFORM todo_app.insert_todo('Task 3', false); | ||
| PERFORM todo_app.insert_todo('Unfinished Task', false); | ||
| PERFORM todo_app.insert_todo('Finished Task', true); | ||
| END$$; | ||
|
|
||
| COMMIT; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| -- Deploy onboarding:todos to pg | ||
| -- requires: appschema | ||
|
|
||
| BEGIN; | ||
|
|
||
| SET client_min_messages = 'warning'; | ||
|
|
||
| CREATE TABLE todo_app.todos ( | ||
| id SERIAL 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; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| -- Revert onboarding:appschema from pg | ||
|
|
||
| BEGIN; | ||
|
|
||
| DROP SCHEMA todo_app; | ||
|
|
||
| COMMIT; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| -- Revert onboarding:insert_todo from pg | ||
|
|
||
| BEGIN; | ||
|
|
||
| DROP FUNCTION todo_app.insert_todo(TEXT, BOOLEAN); | ||
|
|
||
| COMMIT; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| -- Revert onboarding:seed_todo from pg | ||
|
|
||
| BEGIN; | ||
|
|
||
| DELETE FROM todo_app.todos; | ||
| ALTER SEQUENCE todo_app.todos_id_seq RESTART; | ||
|
|
||
| COMMIT; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| -- Revert onboarding:todos from pg | ||
|
|
||
| BEGIN; | ||
|
|
||
| DROP TABLE todo_app.todos; | ||
|
|
||
| COMMIT; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| [core] | ||
| engine = pg | ||
| [deploy] | ||
| verify = true | ||
| [rebase] | ||
| verify = true | ||
| [target "todo_app"] | ||
| uri = db:pg:todo_app | ||
| [engine "pg"] | ||
| target = todo_app |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| %syntax-version=1.0.0 | ||
| %project=onboarding | ||
| %uri=https://github.com/naomiaro/button-onboarding | ||
|
|
||
| appschema 2021-03-19T20:12:31Z Naomi Aro <naomi.aro@gov.bc.ca> # Add schema for all onboarding objects. | ||
| todos [appschema] 2021-03-23T18:08:10Z Naomi Aro <naomi.aro@gov.bc.ca> # Creates a table for the todos. | ||
| insert_todo [todos appschema] 2021-03-23T20:44:59Z Naomi Aro <naomi.aro@gov.bc.ca> # Function to insert TODO | ||
| seed_todo [insert_todo todos appschema] 2021-03-23T23:22:49Z Naomi Aro <naomi.aro@gov.bc.ca> # seed todos table |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| -- Verify onboarding:appschema on pg | ||
|
|
||
| BEGIN; | ||
|
|
||
| SELECT pg_catalog.has_schema_privilege('todo_app', 'usage'); | ||
|
|
||
| ROLLBACK; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| -- Verify onboarding:insert_todo on pg | ||
|
|
||
| BEGIN; | ||
|
|
||
| SELECT has_function_privilege('todo_app.insert_todo(text, boolean)', 'execute'); | ||
|
|
||
| ROLLBACK; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| -- Verify onboarding:seed_todo on pg | ||
|
|
||
| BEGIN; | ||
|
|
||
| DO $$ | ||
| DECLARE | ||
| todos_count INTEGER; | ||
| BEGIN | ||
| todos_count := (SELECT last_value FROM todo_app.todos_id_seq); | ||
| ASSERT todos_count = 5; | ||
| END $$; | ||
|
|
||
| ROLLBACK; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| -- Verify onboarding:todos on pg | ||
|
|
||
| BEGIN; | ||
|
|
||
| SELECT id, task, completed, date_created, date_updated | ||
| FROM todo_app.todos | ||
| WHERE FALSE; | ||
|
|
||
| ROLLBACK; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is part of the SQL standard (while
serialis not), and ensures that you always use a generated id (unless you explicitely useoverride system valuein your insert)