add reserved column to frontends table (#41)

This commit is contained in:
Michael Quigley 2022-11-29 13:45:23 -05:00
parent 65d1539182
commit 189ed81718
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62
3 changed files with 5 additions and 2 deletions

View File

@ -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

View File

@ -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)
);

View File

@ -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'))
);