Skip to content

Commit 8c1916a

Browse files
committed
feat: remove legacy project columns, old settings tables, and app_id defaults
Drop deprecated columns (live_deployment_id, is_rolled_back, depot_project_id) from projects table. Delete environment_build_settings and environment_runtime_settings tables/queries in favor of app-scoped equivalents. Remove DEFAULT '' from app_id columns. Migrate all Go code to use app-scoped queries: github_webhook, verify_handler, deployment_state, build, seed files.
1 parent 86a3b73 commit 8c1916a

File tree

44 files changed

+183
-1026
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+183
-1026
lines changed

cmd/dev/seed/local.go

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ func seedLocal(ctx context.Context, cmd *cli.Command) error {
6565
projectID := uid.New(uid.ProjectPrefix)
6666
projectSlug := fmt.Sprintf("%s-api", slug)
6767
projectName := fmt.Sprintf("%s API", titleCase)
68+
appID := uid.New(uid.AppPrefix)
6869
rootWorkspaceID := "ws_unkey"
6970
rootKeySpaceID := fmt.Sprintf("ks_%s_root_keys", slug)
7071
rootApiID := "api_unkey"
@@ -129,6 +130,23 @@ func seedLocal(ctx context.Context, cmd *cli.Command) error {
129130
return fmt.Errorf("failed to create project: %w", err)
130131
}
131132

133+
err = db.Query.InsertApp(ctx, tx, db.InsertAppParams{
134+
ID: appID,
135+
WorkspaceID: workspaceID,
136+
ProjectID: projectID,
137+
Name: projectName,
138+
Slug: "default",
139+
LiveDeploymentID: sql.NullString{},
140+
IsRolledBack: false,
141+
DepotProjectID: sql.NullString{},
142+
DeleteProtection: sql.NullBool{Valid: false, Bool: false},
143+
CreatedAt: now,
144+
UpdatedAt: sql.NullInt64{Valid: false, Int64: 0},
145+
})
146+
if err != nil {
147+
return fmt.Errorf("failed to create default app: %w", err)
148+
}
149+
132150
err = db.BulkQuery.InsertEnvironments(ctx, tx, []db.InsertEnvironmentParams{
133151
{
134152
ID: previewEnvID,
@@ -153,9 +171,10 @@ func seedLocal(ctx context.Context, cmd *cli.Command) error {
153171
}
154172

155173
// Create default runtime settings for each environment
156-
err = db.BulkQuery.UpsertEnvironmentRuntimeSettings(ctx, tx, []db.UpsertEnvironmentRuntimeSettingsParams{
174+
err = db.BulkQuery.UpsertAppRuntimeSettings(ctx, tx, []db.UpsertAppRuntimeSettingsParams{
157175
{
158176
WorkspaceID: workspaceID,
177+
AppID: appID,
159178
EnvironmentID: previewEnvID,
160179
Port: 8080,
161180
CpuMillicores: 256,
@@ -164,12 +183,13 @@ func seedLocal(ctx context.Context, cmd *cli.Command) error {
164183
Healthcheck: dbtype.NullHealthcheck{Healthcheck: nil, Valid: false},
165184
RegionConfig: dbtype.RegionConfig{},
166185
SentinelConfig: []byte{},
167-
ShutdownSignal: db.EnvironmentRuntimeSettingsShutdownSignalSIGTERM,
186+
ShutdownSignal: db.AppRuntimeSettingsShutdownSignalSIGTERM,
168187
CreatedAt: now,
169188
UpdatedAt: sql.NullInt64{Valid: true, Int64: now},
170189
},
171190
{
172191
WorkspaceID: workspaceID,
192+
AppID: appID,
173193
EnvironmentID: productionEnvID,
174194
Port: 8080,
175195
CpuMillicores: 256,
@@ -178,7 +198,7 @@ func seedLocal(ctx context.Context, cmd *cli.Command) error {
178198
Healthcheck: dbtype.NullHealthcheck{Healthcheck: nil, Valid: false},
179199
RegionConfig: dbtype.RegionConfig{},
180200
SentinelConfig: []byte{},
181-
ShutdownSignal: db.EnvironmentRuntimeSettingsShutdownSignalSIGTERM,
201+
ShutdownSignal: db.AppRuntimeSettingsShutdownSignalSIGTERM,
182202
CreatedAt: now,
183203
UpdatedAt: sql.NullInt64{Valid: true, Int64: now},
184204
},
@@ -188,9 +208,10 @@ func seedLocal(ctx context.Context, cmd *cli.Command) error {
188208
}
189209

190210
// Create default build settings for each environment
191-
err = db.BulkQuery.UpsertEnvironmentBuildSettings(ctx, tx, []db.UpsertEnvironmentBuildSettingsParams{
211+
err = db.BulkQuery.UpsertAppBuildSettings(ctx, tx, []db.UpsertAppBuildSettingsParams{
192212
{
193213
WorkspaceID: workspaceID,
214+
AppID: appID,
194215
EnvironmentID: previewEnvID,
195216
Dockerfile: "Dockerfile",
196217
DockerContext: ".",
@@ -199,6 +220,7 @@ func seedLocal(ctx context.Context, cmd *cli.Command) error {
199220
},
200221
{
201222
WorkspaceID: workspaceID,
223+
AppID: appID,
202224
EnvironmentID: productionEnvID,
203225
Dockerfile: "Dockerfile",
204226
DockerContext: ".",

pkg/db/BUILD.bazel

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ go_library(
3939
"app_runtime_settings_find.sql_generated.go",
4040
"app_runtime_settings_upsert.sql_generated.go",
4141
"app_update_deployments.sql_generated.go",
42+
"app_update_depot_id.sql_generated.go",
4243
"audit_log_find_target_by_id.sql_generated.go",
4344
"audit_log_insert.sql_generated.go",
4445
"audit_log_target_insert.sql_generated.go",
@@ -59,9 +60,7 @@ go_library(
5960
"bulk_deployment_insert.sql_generated.go",
6061
"bulk_deployment_step_insert.sql_generated.go",
6162
"bulk_deployment_topology_insert.sql_generated.go",
62-
"bulk_environment_build_settings_upsert.sql_generated.go",
6363
"bulk_environment_insert.sql_generated.go",
64-
"bulk_environment_runtime_settings_upsert.sql_generated.go",
6564
"bulk_environment_upsert.sql_generated.go",
6665
"bulk_github_repo_connection_insert.sql_generated.go",
6766
"bulk_identity_insert.sql_generated.go",
@@ -136,16 +135,11 @@ go_library(
136135
"deployment_update_openapi_spec.sql_generated.go",
137136
"deployment_update_status.sql_generated.go",
138137
"doc.go",
139-
"environment_build_settings_find_by_environment_id.sql_generated.go",
140-
"environment_build_settings_upsert.sql_generated.go",
141138
"environment_find_by_id.sql_generated.go",
142139
"environment_find_by_project_id_and_slug.sql_generated.go",
143-
"environment_find_with_settings.sql_generated.go",
144140
"environment_insert.sql_generated.go",
145141
"environment_list_by_project.sql_generated.go",
146142
"environment_list_preview.sql_generated.go",
147-
"environment_runtime_settings_find_by_environment_id.sql_generated.go",
148-
"environment_runtime_settings_upsert.sql_generated.go",
149143
"environment_upsert.sql_generated.go",
150144
"environment_variables_find_by_environment_id.sql_generated.go",
151145
"frontline_route_delete_by_fqdn.sql_generated.go",
@@ -248,8 +242,6 @@ go_library(
248242
"project_find_by_id.sql_generated.go",
249243
"project_find_by_workspace_slug.sql_generated.go",
250244
"project_insert.sql_generated.go",
251-
"project_update_deployments.sql_generated.go",
252-
"project_update_depot_id.sql_generated.go",
253245
"querier_bulk_generated.go",
254246
"querier_generated.go",
255247
"queries.go",

pkg/db/app_update_depot_id.sql_generated.go

Lines changed: 35 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/db/bulk_environment_build_settings_upsert.sql_generated.go

Lines changed: 0 additions & 46 deletions
This file was deleted.

pkg/db/bulk_environment_runtime_settings_upsert.sql_generated.go

Lines changed: 0 additions & 58 deletions
This file was deleted.

pkg/db/environment_build_settings_find_by_environment_id.sql_generated.go

Lines changed: 0 additions & 36 deletions
This file was deleted.

pkg/db/environment_build_settings_upsert.sql_generated.go

Lines changed: 0 additions & 61 deletions
This file was deleted.

0 commit comments

Comments
 (0)