Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
117 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,22 @@ | ||
-- Deploy delete_list | ||
-- requires: lists | ||
-- requires: appuser | ||
|
||
BEGIN; | ||
|
||
DELIMITER // | ||
|
||
CREATE FUNCTION delete_list( | ||
list_id BIGINT | ||
) RETURNS BIGINT SQL SECURITY DEFINER | ||
BEGIN | ||
DELETE FROM lists WHERE id = list_id; | ||
RETURN ROW_COUNT(); | ||
END; | ||
// | ||
|
||
DELIMITER ; | ||
|
||
GRANT EXECUTE ON FUNCTION delete_list to flipr; | ||
|
||
COMMIT; |
This file contains 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,25 @@ | ||
-- Deploy insert_list | ||
-- requires: lists | ||
-- requires: appuser | ||
|
||
BEGIN; | ||
|
||
DELIMITER // | ||
|
||
CREATE FUNCTION insert_list( | ||
nickname VARCHAR(512), | ||
name VARCHAR(512), | ||
description TEXT | ||
) RETURNS BIGINT SQL SECURITY DEFINER | ||
BEGIN | ||
INSERT INTO lists (nickname, name, description, created_at) | ||
VALUES (nickname, name, description, UTC_TIMESTAMP(6)); | ||
RETURN LAST_INSERT_ID(); | ||
END; | ||
// | ||
|
||
DELIMITER ; | ||
|
||
GRANT EXECUTE ON FUNCTION insert_list to flipr; | ||
|
||
COMMIT; |
This file contains 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 lists | ||
-- requires: appuser | ||
-- requires: users | ||
|
||
BEGIN; | ||
|
||
CREATE TABLE lists ( | ||
id BIGINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, | ||
nickname VARCHAR(512) NOT NULL REFERENCES users(nickname), | ||
name VARCHAR(512) NOT NULL, | ||
description TEXT NOT NULL, | ||
created_at DATETIME(6) NOT NULL | ||
); | ||
|
||
GRANT SELECT ON TABLE lists TO flipr; | ||
|
||
COMMIT; |
This file contains 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 delete_list | ||
|
||
BEGIN; | ||
|
||
DROP FUNCTION delete_list; | ||
|
||
COMMIT; |
This file contains 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 insert_list | ||
|
||
BEGIN; | ||
|
||
DROP FUNCTION insert_list; | ||
|
||
COMMIT; |
This file contains 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 lists | ||
|
||
BEGIN; | ||
|
||
DROP TABLE lists; | ||
|
||
COMMIT; |
This file contains 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
This file contains 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 @@ | ||
-- Verify delete_list | ||
|
||
BEGIN; | ||
|
||
SELECT sqitch.checkit(COUNT(*), 'Procedure "delete_list" does not exist') | ||
FROM mysql.proc | ||
WHERE db = database() | ||
AND specific_name = 'delete_list'; | ||
|
||
ROLLBACK; |
This file contains 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 @@ | ||
-- Verify insert_list | ||
|
||
BEGIN; | ||
|
||
SELECT sqitch.checkit(COUNT(*), 'Procedure "insert_list" does not exist') | ||
FROM mysql.proc | ||
WHERE db = database() | ||
AND specific_name = 'insert_list'; | ||
|
||
ROLLBACK; |
This file contains 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 @@ | ||
-- Verify lists | ||
|
||
BEGIN; | ||
|
||
SELECT id, nickname, name, description, created_at | ||
FROM lists; | ||
|
||
ROLLBACK; |