Skip to content

Commit 8ba0287

Browse files
committed
first iteration of migration script
1 parent 379cc2f commit 8ba0287

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

migration.sql

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
BEGIN; -- start transaction
2+
3+
SAVEPOINT pastes;
4+
ALTER TABLE pastes DROP COLUMN IF EXISTS author_id CASCADE; -- no longer storing users
5+
ALTER TABLE pastes DROP COLUMN IF EXISTS last_edited CASCADE; -- no longer allowing edits
6+
ALTER TABLE pastes ALTER COLUMN password SET DEFAULT NULL; -- nullable password by default
7+
ALTER TABLE pastes DROP COLUMN IF EXISTS origin_ip CASCADE; -- no longer needed
8+
ALTER TABLE pastes ADD COLUMN IF NOT EXISTS safety TEXT UNIQUE; -- this is how we handle paste deletion.
9+
CREATE UNIQUE INDEX IF NOT EXISTS pastes_safety_idx ON pastes (safety); -- -- Index by safety keys for faster lookup to delete.
10+
11+
SAVEPOINT files;
12+
ALTER TABLE files ALTER COLUMN filename SET NOT NULL; -- always require filename
13+
ALTER TABLE files DROP COLUMN IF EXISTS attachment; -- we don't have these anymore
14+
ALTER TABLE files ADD COLUMN IF NOT EXISTS annotation TEXT;
15+
16+
SAVEPOINT drops;
17+
DROP TABLE IF EXISTS bans CASCADE; -- no longer needed
18+
DROP TABLE IF EXISTS logs CASCADE; -- no longer needed
19+
DROP TABLE IF EXISTS bookmarks CASCADE; -- no longer needed
20+
DROP TABLE IF EXISTS users CASCADE; -- no longer needed
21+
22+
COMMIT;

0 commit comments

Comments
 (0)