From 7cd36021ceda743647262311363afdd56b40d340 Mon Sep 17 00:00:00 2001 From: Michael Quigley Date: Mon, 21 Nov 2022 14:42:25 -0500 Subject: [PATCH] add share_mode and backend_mode to sql structures (#103) --- .../postgresql/003_v0_3_0_service_modes.sql | 13 ++++++++++ .../sql/sqlite3/003_v0_3_0_service_modes.sql | 25 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 controller/store/sql/postgresql/003_v0_3_0_service_modes.sql create mode 100644 controller/store/sql/sqlite3/003_v0_3_0_service_modes.sql diff --git a/controller/store/sql/postgresql/003_v0_3_0_service_modes.sql b/controller/store/sql/postgresql/003_v0_3_0_service_modes.sql new file mode 100644 index 00000000..e7a64bd0 --- /dev/null +++ b/controller/store/sql/postgresql/003_v0_3_0_service_modes.sql @@ -0,0 +1,13 @@ +-- +migrate Up + +create type share_mode as enum ('public', 'private'); +create type backend_mode as enum ('proxy', 'web', 'dav'); + +alter table services + add column share_mode share_mode not null default 'public', + add column backend_mode backend_mode not null default 'proxy'; + +alter table services + alter column share_mode drop default; +alter table services + alter column backend_mode drop default; \ No newline at end of file diff --git a/controller/store/sql/sqlite3/003_v0_3_0_service_modes.sql b/controller/store/sql/sqlite3/003_v0_3_0_service_modes.sql new file mode 100644 index 00000000..dadedb65 --- /dev/null +++ b/controller/store/sql/sqlite3/003_v0_3_0_service_modes.sql @@ -0,0 +1,25 @@ +-- +migrate Up + +alter table services add column share_mode string default 'public'; +alter table services add column backend_mode string default 'proxy'; + +alter table services rename to services_old; +create table services ( + id integer primary key, + environment_id integer constraint fk_environments_services references environments on delete cascade, + z_id string not null unique, + name string not null unique, + frontend string, + backend string, + created_at datetime not null default(strftime('%Y-%m-%d %H:%M:%f', 'now')), + updated_at datetime not null default(strftime('%Y-%m-%d %H:%M:%f', 'now')), + share_mode string not null, + backend_mode string not null + + constraint chk_z_id check (z_id <> ''), + constraint chk_name check (name <> ''), + constraint chk_share_mode check (share_mode == 'public' || share_mode == 'private'), + constraint chk_backend_mode check (backend_mode == 'proxy' || backend_mode == 'web' || backend_mode == 'dav') +); +insert into services select * from services_old; +drop table services_old;