feat(storage): add deployment column + composite indexes for active-apply key (stage A)#194
Open
Kiran01bm wants to merge 1 commit into
Conversation
…pply key (stage A) Additive schema changes preparing the active-apply lock identity to become deployment-aware. No code changes; no behavior change. - apply_target_locks: add 'deployment' column (default '') and new UNIQUE KEY idx_apply_target_v2 (db, type, env, deployment) alongside the existing idx_apply_target. - applies: add KEY idx_database_env_deployment (db, type, env, deployment) alongside the existing idx_database_env. EnsureSchema applies the diff on startup. The empty-string default keeps every legacy row valid. Refs: block#192
There was a problem hiding this comment.
Pull request overview
This PR makes additive MySQL schema updates to prepare SchemaBot’s active-apply identity for a future deployment-aware behavior change, without modifying current Go runtime logic.
Changes:
- Adds
deploymenttoapply_target_lockswith the existing empty-string default convention. - Adds deployment-inclusive composite indexes alongside existing 3-column indexes.
- Preserves current behavior while setting up later stages of the active-apply key migration.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
pkg/schema/mysql/apply_target_locks.sql |
Adds deployment column and a new 4-column unique key for future deployment-aware locking. |
pkg/schema/mysql/applies.sql |
Adds a 4-column composite index for future active-apply queries filtered by deployment. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Additive schema for the active-apply key — zero behaviour change.
apply_target_locks: adddeployment VARCHAR(255) NOT NULL DEFAULT ''andUNIQUE KEY idx_apply_target_v2 (database_name, database_type, environment, deployment)alongside the existingidx_apply_target.applies: add non-uniqueidx_database_env_deployment (database_name, database_type, environment, deployment)alongsideidx_database_env.EnsureSchemaapplies the diff on startup; the empty-string default keeps every legacy row valid.Why
Lays the schema foundation for making the active-apply identity deployment-aware. The behavioural work — moving the active-apply lock down to per-
apply_deploymentsrow granularity and eventually dropping the redundant 3-column indexes — is being delivered through the Multi-Deployment Apply workstream, starting with #205 (apply_deploymentstable + CRUD +tasks.apply_deployment_id).Tracking issue: #192.
Verification
go build ./...,go vet ./..., and the non-integration unit suites forpkg/schema,pkg/storage,pkg/apiall pass.EnsureSchemaintegration coverage (testcontainers MySQL) exercises the new schema on startup; idempotent re-apply is covered byTestEnsureSchema_Idempotent.