From a7d3a63b2899dd8d46ee03b308c504a9bc56b074 Mon Sep 17 00:00:00 2001 From: neri Date: Fri, 30 Sep 2022 15:06:24 +0200 Subject: [PATCH] fix db migration --- Cargo.lock | 2 +- Cargo.toml | 2 +- init-db.sql | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8a76975..50011ca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -427,7 +427,7 @@ dependencies = [ [[package]] name = "datatrash" -version = "1.1.5" +version = "1.1.7" dependencies = [ "actix-files", "actix-governor", diff --git a/Cargo.toml b/Cargo.toml index 39cf15a..55fa49b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "datatrash" -version = "1.1.6" +version = "1.1.7" authors = ["neri"] edition = "2021" diff --git a/init-db.sql b/init-db.sql index 2ae5e82..429b02e 100644 --- a/init-db.sql +++ b/init-db.sql @@ -10,5 +10,8 @@ CREATE TABLE IF NOT EXISTS files ( ALTER TABLE files ADD COLUMN IF NOT EXISTS delete_on_download boolean; ALTER TABLE files ALTER COLUMN delete_on_download set not null; ALTER TABLE files ALTER COLUMN valid_till TYPE timestamptz; -ALTER TABLE files DROP COLUMN IF EXISTS kind; ALTER TABLE files ADD COLUMN IF NOT EXISTS content_type varchar(255); +UPDATE files set content_type = 'text/plain' where kind = 'text'; +UPDATE files set content_type = 'application/octet-stream' where kind = 'binary'; +ALTER TABLE files ALTER COLUMN content_type set not null; +ALTER TABLE files DROP COLUMN IF EXISTS kind;