From a0e94330c7e150e5108ce2ff18a6da984be3391d Mon Sep 17 00:00:00 2001 From: Michael Quigley Date: Thu, 9 Mar 2023 15:08:59 -0500 Subject: [PATCH] added 'deleted' flags to all store objects (#262) --- controller/store/account.go | 1 + controller/store/account_request.go | 1 + controller/store/environment.go | 1 + controller/store/frontend.go | 1 + controller/store/invite_tokens.go | 3 ++- controller/store/password_reset_request.go | 1 + controller/store/share.go | 1 + .../store/sql/postgresql/008_v0_4_0_soft_deletes.sql | 9 +++++++++ controller/store/sql/sqlite3/008_v0_4_0_soft_deletes.sql | 9 +++++++++ controller/store/store.go | 1 + 10 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 controller/store/sql/postgresql/008_v0_4_0_soft_deletes.sql create mode 100644 controller/store/sql/sqlite3/008_v0_4_0_soft_deletes.sql diff --git a/controller/store/account.go b/controller/store/account.go index 1125b32b..cf33ce03 100644 --- a/controller/store/account.go +++ b/controller/store/account.go @@ -12,6 +12,7 @@ type Account struct { Password string Token string Limitless bool + Deleted bool } func (self *Store) CreateAccount(a *Account, tx *sqlx.Tx) (int, error) { diff --git a/controller/store/account_request.go b/controller/store/account_request.go index 7811569d..23b0690e 100644 --- a/controller/store/account_request.go +++ b/controller/store/account_request.go @@ -14,6 +14,7 @@ type AccountRequest struct { Token string Email string SourceAddress string + Deleted bool } func (self *Store) CreateAccountRequest(ar *AccountRequest, tx *sqlx.Tx) (int, error) { diff --git a/controller/store/environment.go b/controller/store/environment.go index 255f1df0..834a2292 100644 --- a/controller/store/environment.go +++ b/controller/store/environment.go @@ -12,6 +12,7 @@ type Environment struct { Host string Address string ZId string + Deleted bool } func (self *Store) CreateEnvironment(accountId int, i *Environment, tx *sqlx.Tx) (int, error) { diff --git a/controller/store/frontend.go b/controller/store/frontend.go index 3ecf16b3..d53f8e8b 100644 --- a/controller/store/frontend.go +++ b/controller/store/frontend.go @@ -13,6 +13,7 @@ type Frontend struct { PublicName *string UrlTemplate *string Reserved bool + Deleted bool } func (str *Store) CreateFrontend(envId int, f *Frontend, tx *sqlx.Tx) (int, error) { diff --git a/controller/store/invite_tokens.go b/controller/store/invite_tokens.go index 3ffa14c3..71d3d757 100644 --- a/controller/store/invite_tokens.go +++ b/controller/store/invite_tokens.go @@ -10,7 +10,8 @@ import ( type InviteToken struct { Model - Token string + Token string + Deleted bool } func (str *Store) CreateInviteTokens(inviteTokens []*InviteToken, tx *sqlx.Tx) error { diff --git a/controller/store/password_reset_request.go b/controller/store/password_reset_request.go index 2677f5ac..9e2ed4ee 100644 --- a/controller/store/password_reset_request.go +++ b/controller/store/password_reset_request.go @@ -13,6 +13,7 @@ type PasswordResetRequest struct { Model Token string AccountId int + Deleted bool } func (self *Store) CreatePasswordResetRequest(prr *PasswordResetRequest, tx *sqlx.Tx) (int, error) { diff --git a/controller/store/share.go b/controller/store/share.go index 5800a36f..b0b68517 100644 --- a/controller/store/share.go +++ b/controller/store/share.go @@ -16,6 +16,7 @@ type Share struct { FrontendEndpoint *string BackendProxyEndpoint *string Reserved bool + Deleted bool } func (self *Store) CreateShare(envId int, shr *Share, tx *sqlx.Tx) (int, error) { diff --git a/controller/store/sql/postgresql/008_v0_4_0_soft_deletes.sql b/controller/store/sql/postgresql/008_v0_4_0_soft_deletes.sql new file mode 100644 index 00000000..6b39841a --- /dev/null +++ b/controller/store/sql/postgresql/008_v0_4_0_soft_deletes.sql @@ -0,0 +1,9 @@ +-- +migrate Up + +alter table account_requests add column deleted boolean not null default(false); +alter table accounts add column deleted boolean not null default(false); +alter table environments add column deleted boolean not null default(false); +alter table frontends add column deleted boolean not null default(false); +alter table invite_tokens add column deleted boolean not null default(false); +alter table password_reset_requests add column deleted boolean not null default(false); +alter table shares add column deleted boolean not null default(false); \ No newline at end of file diff --git a/controller/store/sql/sqlite3/008_v0_4_0_soft_deletes.sql b/controller/store/sql/sqlite3/008_v0_4_0_soft_deletes.sql new file mode 100644 index 00000000..6b39841a --- /dev/null +++ b/controller/store/sql/sqlite3/008_v0_4_0_soft_deletes.sql @@ -0,0 +1,9 @@ +-- +migrate Up + +alter table account_requests add column deleted boolean not null default(false); +alter table accounts add column deleted boolean not null default(false); +alter table environments add column deleted boolean not null default(false); +alter table frontends add column deleted boolean not null default(false); +alter table invite_tokens add column deleted boolean not null default(false); +alter table password_reset_requests add column deleted boolean not null default(false); +alter table shares add column deleted boolean not null default(false); \ No newline at end of file diff --git a/controller/store/store.go b/controller/store/store.go index de58e0a3..60e98f60 100644 --- a/controller/store/store.go +++ b/controller/store/store.go @@ -18,6 +18,7 @@ type Model struct { Id int CreatedAt time.Time UpdatedAt time.Time + Deleted bool } type Config struct {