Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(db): added deleted column to environments table #2044

Merged
merged 7 commits into from
Oct 16, 2024
Merged
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ALTER TABLE environments
ADD COLUMN IF NOT EXISTS deleted bool
DEFAULT false NOT NULL;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ALTER TABLE environments
ADD COLUMN deleted bool
DEFAULT false NOT NULL;
6 changes: 4 additions & 2 deletions pkg/db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -5123,7 +5123,7 @@ func (h *DBHandler) DBSelectEnvironment(ctx context.Context, tx *sql.Tx, environ
`
SELECT created, version, name, json, applications
FROM environments
WHERE name=?
WHERE name=? AND deleted=false
ORDER BY version DESC
LIMIT 1;
`,
Expand Down Expand Up @@ -5199,6 +5199,7 @@ ON
AND latest.name = environments.name
WHERE
environments.name IN (?` + strings.Repeat(",?", len(environmentNames)-1) + `)
AND deleted=false
LIMIT ?
`,
)
Expand Down Expand Up @@ -5277,7 +5278,7 @@ func (h *DBHandler) DBWriteEnvironment(ctx context.Context, tx *sql.Tx, environm
}

insertQuery := h.AdaptQuery(
"INSERT Into environments (created, version, name, json, applications) VALUES (?, ?, ?, ?, ?);",
"INSERT Into environments (created, version, name, json, applications, deleted) VALUES (?, ?, ?, ?, ?, ?);",
)
now, err := h.DBReadTransactionTimestamp(ctx, tx)
if err != nil {
Expand All @@ -5291,6 +5292,7 @@ func (h *DBHandler) DBWriteEnvironment(ctx context.Context, tx *sql.Tx, environm
environmentName,
jsonToInsert,
string(applicationsJson),
false,
)
if err != nil {
return fmt.Errorf("could not write environment %s with config %v to environments table, error: %w", environmentName, environmentConfig, err)
Expand Down
Loading