Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 26 additions & 4 deletions cmd/dev/seed/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func seedLocal(ctx context.Context, cmd *cli.Command) error {
projectID := uid.New(uid.ProjectPrefix)
projectSlug := fmt.Sprintf("%s-api", slug)
projectName := fmt.Sprintf("%s API", titleCase)
appID := uid.New(uid.AppPrefix)
rootWorkspaceID := "ws_unkey"
rootKeySpaceID := fmt.Sprintf("ks_%s_root_keys", slug)
rootApiID := "api_unkey"
Expand Down Expand Up @@ -129,6 +130,23 @@ func seedLocal(ctx context.Context, cmd *cli.Command) error {
return fmt.Errorf("failed to create project: %w", err)
}

err = db.Query.InsertApp(ctx, tx, db.InsertAppParams{
ID: appID,
WorkspaceID: workspaceID,
ProjectID: projectID,
Name: projectName,
Slug: "default",
LiveDeploymentID: sql.NullString{},
IsRolledBack: false,
DepotProjectID: sql.NullString{},
DeleteProtection: sql.NullBool{Valid: false, Bool: false},
CreatedAt: now,
UpdatedAt: sql.NullInt64{Valid: false, Int64: 0},
})
if err != nil {
return fmt.Errorf("failed to create default app: %w", err)
}

err = db.BulkQuery.InsertEnvironments(ctx, tx, []db.InsertEnvironmentParams{
{
ID: previewEnvID,
Expand All @@ -153,9 +171,10 @@ func seedLocal(ctx context.Context, cmd *cli.Command) error {
}

// Create default runtime settings for each environment
err = db.BulkQuery.UpsertEnvironmentRuntimeSettings(ctx, tx, []db.UpsertEnvironmentRuntimeSettingsParams{
err = db.BulkQuery.UpsertAppRuntimeSettings(ctx, tx, []db.UpsertAppRuntimeSettingsParams{
{
WorkspaceID: workspaceID,
AppID: appID,
EnvironmentID: previewEnvID,
Port: 8080,
CpuMillicores: 256,
Expand All @@ -164,12 +183,13 @@ func seedLocal(ctx context.Context, cmd *cli.Command) error {
Healthcheck: dbtype.NullHealthcheck{Healthcheck: nil, Valid: false},
RegionConfig: dbtype.RegionConfig{},
SentinelConfig: []byte{},
ShutdownSignal: db.EnvironmentRuntimeSettingsShutdownSignalSIGTERM,
ShutdownSignal: db.AppRuntimeSettingsShutdownSignalSIGTERM,
CreatedAt: now,
UpdatedAt: sql.NullInt64{Valid: true, Int64: now},
},
{
WorkspaceID: workspaceID,
AppID: appID,
EnvironmentID: productionEnvID,
Port: 8080,
CpuMillicores: 256,
Expand All @@ -178,7 +198,7 @@ func seedLocal(ctx context.Context, cmd *cli.Command) error {
Healthcheck: dbtype.NullHealthcheck{Healthcheck: nil, Valid: false},
RegionConfig: dbtype.RegionConfig{},
SentinelConfig: []byte{},
ShutdownSignal: db.EnvironmentRuntimeSettingsShutdownSignalSIGTERM,
ShutdownSignal: db.AppRuntimeSettingsShutdownSignalSIGTERM,
CreatedAt: now,
UpdatedAt: sql.NullInt64{Valid: true, Int64: now},
},
Expand All @@ -188,9 +208,10 @@ func seedLocal(ctx context.Context, cmd *cli.Command) error {
}

// Create default build settings for each environment
err = db.BulkQuery.UpsertEnvironmentBuildSettings(ctx, tx, []db.UpsertEnvironmentBuildSettingsParams{
err = db.BulkQuery.UpsertAppBuildSettings(ctx, tx, []db.UpsertAppBuildSettingsParams{
{
WorkspaceID: workspaceID,
AppID: appID,
EnvironmentID: previewEnvID,
Dockerfile: "Dockerfile",
DockerContext: ".",
Expand All @@ -199,6 +220,7 @@ func seedLocal(ctx context.Context, cmd *cli.Command) error {
},
{
WorkspaceID: workspaceID,
AppID: appID,
EnvironmentID: productionEnvID,
Dockerfile: "Dockerfile",
DockerContext: ".",
Expand Down
11 changes: 2 additions & 9 deletions pkg/db/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ go_library(
"app_runtime_settings_find.sql_generated.go",
"app_runtime_settings_upsert.sql_generated.go",
"app_update_deployments.sql_generated.go",
"app_update_depot_id.sql_generated.go",
"audit_log_find_target_by_id.sql_generated.go",
"audit_log_insert.sql_generated.go",
"audit_log_target_insert.sql_generated.go",
Expand All @@ -57,9 +58,7 @@ go_library(
"bulk_deployment_insert.sql_generated.go",
"bulk_deployment_step_insert.sql_generated.go",
"bulk_deployment_topology_insert.sql_generated.go",
"bulk_environment_build_settings_upsert.sql_generated.go",
"bulk_environment_insert.sql_generated.go",
"bulk_environment_runtime_settings_upsert.sql_generated.go",
"bulk_environment_upsert.sql_generated.go",
"bulk_github_repo_connection_insert.sql_generated.go",
"bulk_identity_insert.sql_generated.go",
Expand Down Expand Up @@ -118,6 +117,7 @@ go_library(
"deployment_delete_instances.sql_generated.go",
"deployment_find_by_id.sql_generated.go",
"deployment_find_by_k8s_name.sql_generated.go",
"deployment_find_latest_ready_by_app_and_env.sql_generated.go",
"deployment_insert.sql_generated.go",
"deployment_list_by_environment_id_and_status.sql_generated.go",
"deployment_step_end.sql_generated.go",
Expand All @@ -134,15 +134,10 @@ go_library(
"deployment_update_openapi_spec.sql_generated.go",
"deployment_update_status.sql_generated.go",
"doc.go",
"environment_build_settings_find_by_environment_id.sql_generated.go",
"environment_build_settings_upsert.sql_generated.go",
"environment_find_by_id.sql_generated.go",
"environment_find_by_project_id_and_slug.sql_generated.go",
"environment_find_with_settings.sql_generated.go",
"environment_insert.sql_generated.go",
"environment_list_preview.sql_generated.go",
"environment_runtime_settings_find_by_environment_id.sql_generated.go",
"environment_runtime_settings_upsert.sql_generated.go",
"environment_upsert.sql_generated.go",
"environment_variables_find_by_environment_id.sql_generated.go",
"frontline_route_delete_by_fqdn.sql_generated.go",
Expand Down Expand Up @@ -245,8 +240,6 @@ go_library(
"project_find_by_id.sql_generated.go",
"project_find_by_workspace_slug.sql_generated.go",
"project_insert.sql_generated.go",
"project_update_deployments.sql_generated.go",
"project_update_depot_id.sql_generated.go",
"querier_bulk_generated.go",
"querier_generated.go",
"queries.go",
Expand Down
35 changes: 35 additions & 0 deletions pkg/db/app_update_depot_id.sql_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 0 additions & 46 deletions pkg/db/bulk_environment_build_settings_upsert.sql_generated.go

This file was deleted.

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

Loading