Skip to content

feat(storage): add deployment column + composite indexes for active-apply key (stage A)#194

Open
Kiran01bm wants to merge 1 commit into
block:mainfrom
Kiran01bm:kiran01bm/deployment-aware-apply-target-lock-stage-a-schema
Open

feat(storage): add deployment column + composite indexes for active-apply key (stage A)#194
Kiran01bm wants to merge 1 commit into
block:mainfrom
Kiran01bm:kiran01bm/deployment-aware-apply-target-lock-stage-a-schema

Conversation

@Kiran01bm
Copy link
Copy Markdown
Collaborator

@Kiran01bm Kiran01bm commented May 29, 2026

What

Additive schema for the active-apply key — zero behaviour change.

  • apply_target_locks: add deployment VARCHAR(255) NOT NULL DEFAULT '' and UNIQUE KEY idx_apply_target_v2 (database_name, database_type, environment, deployment) alongside the existing idx_apply_target.
  • applies: add non-unique idx_database_env_deployment (database_name, database_type, environment, deployment) alongside idx_database_env.

EnsureSchema applies 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_deployments row granularity and eventually dropping the redundant 3-column indexes — is being delivered through the Multi-Deployment Apply workstream, starting with #205 (apply_deployments table + CRUD + tasks.apply_deployment_id).

Tracking issue: #192.

Verification

go build ./..., go vet ./..., and the non-integration unit suites for pkg/schema, pkg/storage, pkg/api all pass. EnsureSchema integration coverage (testcontainers MySQL) exercises the new schema on startup; idempotent re-apply is covered by TestEnsureSchema_Idempotent.

…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
Copilot AI review requested due to automatic review settings May 29, 2026 04:51
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 deployment to apply_target_locks with 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.

@Kiran01bm Kiran01bm marked this pull request as ready for review May 29, 2026 04:58
@Kiran01bm Kiran01bm requested review from aparajon and morgo as code owners May 29, 2026 04:58
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants