From ba367555e1639a05a76c6b25b894caed1ad2dbd6 Mon Sep 17 00:00:00 2001 From: Nick Krichevsky Date: Sun, 17 Mar 2019 18:02:35 -0400 Subject: [PATCH] Add clump migration --- migrations/20190317174940_clumps.sql | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 migrations/20190317174940_clumps.sql diff --git a/migrations/20190317174940_clumps.sql b/migrations/20190317174940_clumps.sql new file mode 100644 index 0000000..d213159 --- /dev/null +++ b/migrations/20190317174940_clumps.sql @@ -0,0 +1,17 @@ +-- +goose Up +-- SQL in this section is executed when the migration is applied. + +ALTER TABLE paste RENAME COLUMN title TO filename; +CREATE TABLE clump ( + clumpID SERIAL PRIMARY KEY, + title VARCHAR(512), + handle uuid UNIQUE +); +ALTER TABLE paste ADD COLUMN clumpID INTEGER DEFAULT NULL REFERENCES clump(clumpID) ON DELETE CASCADE; + +-- +goose Down +-- SQL in this section is executed when the migration is rolled back. + +ALTER TABLE paste RENAME COLUMN filename TO paste; +ALTER TABLE paste DROP COLUMN clumpID; +DROP TABLE clump;