Skip to content

Commit 991c9cd

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 991c9cd

File tree

80 files changed

+489
-1181
lines changed

Some content is hidden

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

80 files changed

+489
-1181
lines changed

cmd/dev/seed/local.go

Lines changed: 25 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,22 @@ 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+
DepotProjectID: sql.NullString{},
141+
DeleteProtection: sql.NullBool{Valid: false, Bool: false},
142+
CreatedAt: now,
143+
UpdatedAt: sql.NullInt64{Valid: false, Int64: 0},
144+
})
145+
if err != nil {
146+
return fmt.Errorf("failed to create default app: %w", err)
147+
}
148+
132149
err = db.BulkQuery.InsertEnvironments(ctx, tx, []db.InsertEnvironmentParams{
133150
{
134151
ID: previewEnvID,
@@ -153,9 +170,10 @@ func seedLocal(ctx context.Context, cmd *cli.Command) error {
153170
}
154171

155172
// Create default runtime settings for each environment
156-
err = db.BulkQuery.UpsertEnvironmentRuntimeSettings(ctx, tx, []db.UpsertEnvironmentRuntimeSettingsParams{
173+
err = db.BulkQuery.UpsertAppRuntimeSettings(ctx, tx, []db.UpsertAppRuntimeSettingsParams{
157174
{
158175
WorkspaceID: workspaceID,
176+
AppID: appID,
159177
EnvironmentID: previewEnvID,
160178
Port: 8080,
161179
CpuMillicores: 256,
@@ -164,12 +182,13 @@ func seedLocal(ctx context.Context, cmd *cli.Command) error {
164182
Healthcheck: dbtype.NullHealthcheck{Healthcheck: nil, Valid: false},
165183
RegionConfig: dbtype.RegionConfig{},
166184
SentinelConfig: []byte{},
167-
ShutdownSignal: db.EnvironmentRuntimeSettingsShutdownSignalSIGTERM,
185+
ShutdownSignal: db.AppRuntimeSettingsShutdownSignalSIGTERM,
168186
CreatedAt: now,
169187
UpdatedAt: sql.NullInt64{Valid: true, Int64: now},
170188
},
171189
{
172190
WorkspaceID: workspaceID,
191+
AppID: appID,
173192
EnvironmentID: productionEnvID,
174193
Port: 8080,
175194
CpuMillicores: 256,
@@ -178,7 +197,7 @@ func seedLocal(ctx context.Context, cmd *cli.Command) error {
178197
Healthcheck: dbtype.NullHealthcheck{Healthcheck: nil, Valid: false},
179198
RegionConfig: dbtype.RegionConfig{},
180199
SentinelConfig: []byte{},
181-
ShutdownSignal: db.EnvironmentRuntimeSettingsShutdownSignalSIGTERM,
200+
ShutdownSignal: db.AppRuntimeSettingsShutdownSignalSIGTERM,
182201
CreatedAt: now,
183202
UpdatedAt: sql.NullInt64{Valid: true, Int64: now},
184203
},
@@ -188,9 +207,10 @@ func seedLocal(ctx context.Context, cmd *cli.Command) error {
188207
}
189208

190209
// Create default build settings for each environment
191-
err = db.BulkQuery.UpsertEnvironmentBuildSettings(ctx, tx, []db.UpsertEnvironmentBuildSettingsParams{
210+
err = db.BulkQuery.UpsertAppBuildSettings(ctx, tx, []db.UpsertAppBuildSettingsParams{
192211
{
193212
WorkspaceID: workspaceID,
213+
AppID: appID,
194214
EnvironmentID: previewEnvID,
195215
Dockerfile: "Dockerfile",
196216
DockerContext: ".",
@@ -199,6 +219,7 @@ func seedLocal(ctx context.Context, cmd *cli.Command) error {
199219
},
200220
{
201221
WorkspaceID: workspaceID,
222+
AppID: appID,
202223
EnvironmentID: productionEnvID,
203224
Dockerfile: "Dockerfile",
204225
DockerContext: ".",

pkg/db/BUILD.bazel

Lines changed: 2 additions & 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",
@@ -120,6 +119,7 @@ go_library(
120119
"deployment_delete_instances.sql_generated.go",
121120
"deployment_find_by_id.sql_generated.go",
122121
"deployment_find_by_k8s_name.sql_generated.go",
122+
"deployment_find_latest_ready_by_app_and_env.sql_generated.go",
123123
"deployment_insert.sql_generated.go",
124124
"deployment_list_by_environment_id_and_status.sql_generated.go",
125125
"deployment_step_end.sql_generated.go",
@@ -136,16 +136,11 @@ go_library(
136136
"deployment_update_openapi_spec.sql_generated.go",
137137
"deployment_update_status.sql_generated.go",
138138
"doc.go",
139-
"environment_build_settings_find_by_environment_id.sql_generated.go",
140-
"environment_build_settings_upsert.sql_generated.go",
141139
"environment_find_by_id.sql_generated.go",
142140
"environment_find_by_project_id_and_slug.sql_generated.go",
143-
"environment_find_with_settings.sql_generated.go",
144141
"environment_insert.sql_generated.go",
145142
"environment_list_by_project.sql_generated.go",
146143
"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",
149144
"environment_upsert.sql_generated.go",
150145
"environment_variables_find_by_environment_id.sql_generated.go",
151146
"frontline_route_delete_by_fqdn.sql_generated.go",
@@ -248,8 +243,6 @@ go_library(
248243
"project_find_by_id.sql_generated.go",
249244
"project_find_by_workspace_slug.sql_generated.go",
250245
"project_insert.sql_generated.go",
251-
"project_update_deployments.sql_generated.go",
252-
"project_update_depot_id.sql_generated.go",
253246
"querier_bulk_generated.go",
254247
"querier_generated.go",
255248
"queries.go",

pkg/db/app_find_by_id.sql_generated.go

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

pkg/db/app_find_by_project_and_slug.sql_generated.go

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

pkg/db/app_find_with_settings.sql_generated.go

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

pkg/db/app_insert.sql_generated.go

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

pkg/db/app_list_by_project.sql_generated.go

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

pkg/db/app_list_siblings.sql_generated.go

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

pkg/db/app_update_deployments.sql_generated.go

Lines changed: 1 addition & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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.

0 commit comments

Comments
 (0)