fix/local-seed-region by Flo4604 ยท Pull Request #5296 ยท unkeyed/unkey
๐ Walkthrough
Walkthrough
Adds region initialization to local seed, adds single and bulk upsert SQL/Go for app_regional_settings and interface entries, registers generated files in Bazel, and tightens a uniqueness constraint on cilium_network_policies.
Changes
| Cohort / File(s) | Summary |
|---|---|
Seed Configuration cmd/dev/seed/local.go |
Initializes a Region (Name: "local", Platform: "dev") and upserts AppRegionalSettings for preview and production environments with replicas = 1. |
SQL Query Definition pkg/db/queries/app_regional_settings_upsert.sql |
Adds UpsertAppRegionalSettings: INSERT ... ON DUPLICATE KEY UPDATE for workspace_id, app_id, environment_id, region_id, replicas, created_at, updated_at. |
Generated DB code pkg/db/app_regional_settings_upsert.sql_generated.go, pkg/db/bulk_app_regional_settings_upsert.sql_generated.go |
Adds UpsertAppRegionalSettingsParams and generated single and bulk UpsertAppRegionalSettings implementations; bulk builder composes multi-row INSERT with ON DUPLICATE KEY UPDATE. |
Database interfaces pkg/db/querier_generated.go, pkg/db/querier_bulk_generated.go |
Adds UpsertAppRegionalSettings signatures to Querier and BulkQuerier interfaces (note: duplicate insertion observed in querier_generated.go). |
Build config pkg/db/BUILD.bazel |
Registers the two new generated Go files in the db go_library srcs. |
Schema change pkg/mysql/schema.sql |
Modifies unique constraint on cilium_network_policies from UNIQUE(deployment_id,region_id) to UNIQUE(deployment_id,region_id,k8s_name). |
Sequence Diagram(s)
mermaid
sequenceDiagram
participant Seed as "cmd/dev/seed/local"
participant DB as "pkg/db (Querier/BulkQueries)"
participant MySQL as "MySQL (app_regional_settings)"
rect rgba(0,128,0,0.5)
Seed->>DB: Create or get Region (name=local, platform=dev)
DB->>MySQL: INSERT/SELECT region
MySQL-->>DB: region_id
DB-->>Seed: region_id
end
rect rgba(0,0,255,0.5)
Seed->>DB: Upsert AppRegionalSettings (preview & production, replicas=1)
DB->>MySQL: Exec single or bulk INSERT ... ON DUPLICATE KEY UPDATE
MySQL-->>DB: OK
DB-->>Seed: Acknowledgement
Estimated code review effort
๐ฏ 3 (Moderate) | โฑ๏ธ ~25 minutes
๐ฅ Pre-merge checks | โ 2 | โ 1
โ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | โ ๏ธ Warning | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. | Write docstrings for the functions missing them to satisfy the coverage threshold. |
โ Passed checks (2 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | โ Passed | The title 'fix/local-seed-region' describes the main change in the PR, which adds local region seeding functionality for development environments. |
| Description check | โ Passed | The description covers the key aspects of the PR: what it does, the type of change (enhancement), testing instructions, and includes checklist items as per the template. |
โ๏ธ Tip: You can configure your own custom pre-merge checks in the settings.
โจ Finishing Touches
- ๐ Generate docstrings (stacked PR)
- ๐ Generate docstrings (commit on current branch)
๐งช Generate unit tests (beta)
- Create PR with unit tests
- Post copyable unit tests in a comment
- Commit unit tests in branch
03-12-fix_local-seed-region
๐ Coding Plan
- Generate coding plan for human review comments
Comment @coderabbitai help to get the list of available commands and usage tips.