-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
base: master
Are you sure you want to change the base?
Conversation
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
There was a problem hiding this 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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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` |
There was a problem hiding this comment.
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?
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