From 189ed81718c84626fc0553e5370a9bc2398d03f4 Mon Sep 17 00:00:00 2001 From: Michael Quigley Date: Tue, 29 Nov 2022 13:45:23 -0500 Subject: [PATCH] add reserved column to frontends table (#41) --- controller/store/frontend.go | 5 +++-- .../store/sql/postgresql/002_v0_3_0_frontend_selection.sql | 1 + .../store/sql/sqlite3/002_v0_3_0_frontend_selection.sql | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/controller/store/frontend.go b/controller/store/frontend.go index 64ca6312..d820b367 100644 --- a/controller/store/frontend.go +++ b/controller/store/frontend.go @@ -11,15 +11,16 @@ type Frontend struct { Name string ZId string PublicName *string + Reserved bool } func (str *Store) CreateFrontend(envId int, f *Frontend, tx *sqlx.Tx) (int, error) { - stmt, err := tx.Prepare("insert into frontends (environment_id, name, z_id, public_name) values ($1, $2, $3, $4) returning id") + stmt, err := tx.Prepare("insert into frontends (environment_id, name, z_id, public_name, reserved) values ($1, $2, $3, $4, $5) returning id") if err != nil { return 0, errors.Wrap(err, "error preparing frontends insert statement") } var id int - if err := stmt.QueryRow(envId, f.Name, f.ZId, f.PublicName).Scan(&id); err != nil { + if err := stmt.QueryRow(envId, f.Name, f.ZId, f.PublicName, f.Reserved).Scan(&id); err != nil { return 0, errors.Wrap(err, "error executing frontends insert statement") } return id, nil diff --git a/controller/store/sql/postgresql/002_v0_3_0_frontend_selection.sql b/controller/store/sql/postgresql/002_v0_3_0_frontend_selection.sql index c319c17b..addf60b7 100644 --- a/controller/store/sql/postgresql/002_v0_3_0_frontend_selection.sql +++ b/controller/store/sql/postgresql/002_v0_3_0_frontend_selection.sql @@ -6,6 +6,7 @@ create table frontends ( name varchar(32) not null unique, z_id varchar(32) not null unique, public_name varchar(64) unique, + reserved boolean not null default(false), created_at timestamptz not null default(current_timestamp), updated_at timestamptz not null default(current_timestamp) ); diff --git a/controller/store/sql/sqlite3/002_v0_3_0_frontend_selection.sql b/controller/store/sql/sqlite3/002_v0_3_0_frontend_selection.sql index 4f3bc302..754023f4 100644 --- a/controller/store/sql/sqlite3/002_v0_3_0_frontend_selection.sql +++ b/controller/store/sql/sqlite3/002_v0_3_0_frontend_selection.sql @@ -23,6 +23,7 @@ create table frontends ( name varchar(32) not null unique, z_id varchar(32) not null unique, public_name varchar(64) unique, + reserved boolean not null default(false), 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')) );