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
"scripts": { | |
"migrate": "flock-migrate", | |
"migrate-up": "npm run migrate up", | |
"migrate-down": "npm run migrate down" | |
} |
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
set -eo pipefail | |
command="up" | |
input=$(echo "$2" | awk '{print tolower($0)}') | |
if [ "$input" == "down" ] ; then | |
command="down" | |
elif [ "$input" == "create" ] ; then | |
echo "Please do not attempt to create migrations directly from the server. Check out flock-core-migrations, and do this there!" |
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
BEGIN; | |
SELECT plan(2); | |
INSERT INTO payments(1, 99, 'failed'); | |
PREPARE insert_failure AS | |
INSERT INTO payments VALUES(10, -7, 'failed'); | |
PREPARE second_failure AS | |
INSERT INTO policies VALUES(11, 1, 'annual'); |
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
CREATE SEQUENCE IF NOT EXISTS ids | |
START 1; | |
CREATE TABLE IF NOT EXISTS payments ( | |
id BIGINT NOT NULL PRIMARY KEY DEFAULT nextval('ids'), | |
amount BIGINT NOT NULL CHECK((amount > 0) AND (amount <= 100)), | |
status TEXT DEFAULT 'failed' CONSTRAINT status_validity_check CHECK (type IN ('failed', 'succeeded', 'pending')) | |
); |
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
BEGIN; | |
SELECT plan(15); | |
SELECT columns_are( 'flock_payments', 'payments', ARRAY[ | |
'id', | |
'policy_id' | |
]); | |
SELECT triggers_are( 'flock_payments', 'payments', ARRAY[]::text[]); | |
SELECT indexes_are( 'flock_payments', 'payments', ARRAY['payments_pkey']); |
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
"scripts": { | |
"test": "pg_prove -U $FLOCK_PG_USERNAME -d $FLOCK_PG_DATABASE tests/*.sql tests/**/*.sql local-tests/*.sql" | |
} |
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
"bin": { | |
"installpgtapci": "bin/installpgtapci" | |
} |
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
#!/bin/bash | |
yes | sudo cpan TAP::Parser::SourceHandler::pgTAP | |
code=$? | |
if [[ $code -eq 0 ]] ; then | |
echo "0" | |
elif [[ $code -eq 141 ]] ; then | |
echo "141" | |
else |
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
export const up = (db, callback) => db.runSql(` | |
ALTER TABLE flock_payments.payments | |
DROP CONSTRAINT payments_fkey; | |
ALTER TABLE flock_policies.policies | |
ALTER COLUMN id TYPE INT; | |
ALTER TABLE flock_payments.payments | |
ALTER COLUMN policy_id TYPE INT; |
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
export const up = (db, callback) => db.runSql(` | |
CREATE TABLE IF NOT EXISTS flock_payments.payments( | |
id bigint NOT NULL PRIMARY KEY, | |
policy_id bigint NOT NULL REFERENCES flock_policies.policies (id) | |
); | |
`, callback) |
NewerOlder