Proper DB migration

This commit is contained in:
Alex Ling
2021-01-16 17:11:57 +00:00
parent 1065b430e3
commit f7a360c2d8
8 changed files with 119 additions and 49 deletions

20
migration/thumbnails.3.cr Normal file
View File

@@ -0,0 +1,20 @@
class CreateThumbnails < MG::Base
def up : String
<<-SQL
CREATE TABLE IF NOT EXISTS thumbnails (
id TEXT NOT NULL,
data BLOB NOT NULL,
filename TEXT NOT NULL,
mime TEXT NOT NULL,
size INTEGER NOT NULL
);
CREATE UNIQUE INDEX IF NOT EXISTS tn_index ON thumbnails (id);
SQL
end
def down : String
<<-SQL
DROP TABLE thumbnails;
SQL
end
end