Skip to content

CLAUDE: add schema-migration command #151572

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dhartunian
Copy link
Collaborator

This command can be invoked in Claude Code using
/schema-migration <prompt> in order to generate code for a new schema migration.

The instructions were generated by Claude Code with some minor tweaks.

Epic: None
Release note: None

This command can be invoked in Claude Code using
`/schema-migration <prompt>` in order to generate code for a new
schema migration.

The instructions were generated by Claude Code with some minor tweaks.

Epic: None
Release note: None
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Collaborator

@rafiss rafiss left a comment

Choose a reason for hiding this comment

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

The name "schema migration" threw me off here. From what i understand from the md file, this is more about the upgrade steps defined in pkg/upgrade (formerly known as pkg/migration). "Schema migration" may be a bit misleading, since not all upgrades involve schema migrations -- only the ones that are about modifying the system database schema do that.

@@ -0,0 +1,447 @@
# CockroachDB Schema Migration Construction
Copy link
Member

Choose a reason for hiding this comment

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

I'd call these "upgrade migration" throughout


**Important:** Always use the next available even Internal number. Check existing versions to see what's already used.

### 2. Create the Migration File
Copy link
Member

Choose a reason for hiding this comment

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

I personally prefer to reverse the order here: I only add the upgrade after I've modified the bootstrap catalog and tested my feature against the updated schema, since I often need to iterate on the schema a little as I do. Once I've arrived at a schema that works for my feature, I add the upgrade for existing clusters once, rather than doing that first and needing to keep updating it as I tweak my new schema.

CREATE INDEX IF NOT EXISTS your_index ON table (column)
```

2. **Use explicit column families** for new columns:
Copy link
Member

Choose a reason for hiding this comment

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

huh? why?


### 2. Create the Migration File

**File:** `pkg/upgrade/upgrades/v25_4_your_feature_name.go`
Copy link
Member

Choose a reason for hiding this comment

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

I think this should mention the rule about the version in the filename (and test).
maybe ask Claude to read https://cockroachlabs.atlassian.net/wiki/spaces/ENG/pages/2775876082/Guidelines+for+writing+cluster+version-specific+code+and+using+version+gates and ensure these instruction reflect its content?

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.

4 participants