一键导入
modify-sql-fields
TRIGGER when user asks to change, rename, or retype fields, properties, or columns of a SQL CRUD microservice's object.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
TRIGGER when user asks to change, rename, or retype fields, properties, or columns of a SQL CRUD microservice's object.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | modify-sql-fields |
| description | TRIGGER when user asks to change, rename, or retype fields, properties, or columns of a SQL CRUD microservice's object. |
CRITICAL: Read and analyze this microservice before starting. Do NOT explore or analyze other microservices unless explicitly instructed to do so. The instructions in this skill are self-contained to this microservice.
IMPORTANT: MyNoun, MyNounKey, mynoun, and mynounapi are placeholders for the actual object, its key, directory, and API package of the microservice.
Copy this checklist and track your progress:
Changing fields of the object:
- [ ] Step 1: Read Local CLAUDE.md File
- [ ] Step 2: Update the Type Definition of the Object
- [ ] Step 3: Update the Type Definition of the Query
- [ ] Step 4: Update Database Schema
- [ ] Step 5: Update Mappings of Column Names to Object Fields
- [ ] Step 6: Update Query Conditions
- [ ] Step 7: Update Integration Tests
- [ ] Step 8: Housekeeping
CLAUDE.md FileRead the local CLAUDE.md file in the microservice's directory. It contains microservice-specific instructions that should take precedence over global instructions.
Find the type definition of the object in mynounapi/object.go in the API directory of the microservice.
Change the fields in the type definition of the struct appropriately.
Change the code in the object's Validate method appropriately.
Find the type definition of the query in mynounapi/query.go in the API directory of the microservice.
Change the fields in the type definition of the struct appropriately.
Change the code in the query's Validate method appropriately.
Skip this step if the changes do not necessitate a database schema change. For example, renaming only a Go field or JSON tag without changing the database column name does not require a schema change.
Create a new migration script file in resources/sql with an incremental file name. IMPORTANT: Do not edit an existing migration file.
Append ALTER TABLE statements to change the type, size or constraints of columns, if applicable. For pgx, each aspect of the column (type, nullability, default) requires a separate statement - only include the statements relevant to the change. For mssql, if the column already has a default constraint from a prior migration, drop it before adding the new one.
-- DRIVER: mysql
ALTER TABLE my_table
MODIFY COLUMN modified_column VARCHAR(384) NOT NULL DEFAULT '',
MODIFY COLUMN changed_column BIGINT NOT NULL DEFAULT 0;
-- DRIVER: pgx
ALTER TABLE my_table ALTER COLUMN modified_column TYPE VARCHAR(384);
-- DRIVER: pgx
ALTER TABLE my_table ALTER COLUMN modified_column SET NOT NULL;
-- DRIVER: pgx
ALTER TABLE my_table ALTER COLUMN modified_column SET DEFAULT '';
-- DRIVER: pgx
ALTER TABLE my_table ALTER COLUMN changed_column TYPE BIGINT;
-- DRIVER: pgx
ALTER TABLE my_table ALTER COLUMN changed_column SET NOT NULL;
-- DRIVER: pgx
ALTER TABLE my_table ALTER COLUMN changed_column SET DEFAULT 0;
-- DRIVER: mssql
ALTER TABLE my_table DROP CONSTRAINT my_table_df_modified_column;
-- DRIVER: mssql
ALTER TABLE my_table DROP CONSTRAINT my_table_df_changed_column;
-- DRIVER: mssql
ALTER TABLE my_table ALTER COLUMN modified_column NVARCHAR(384) NOT NULL;
-- DRIVER: mssql
ALTER TABLE my_table ALTER COLUMN changed_column BIGINT NOT NULL;
-- DRIVER: mssql
ALTER TABLE my_table ADD CONSTRAINT my_table_df_modified_column DEFAULT '' FOR modified_column;
-- DRIVER: mssql
ALTER TABLE my_table ADD CONSTRAINT my_table_df_changed_column DEFAULT 0 FOR changed_column;
Append ALTER TABLE or EXEC statements to rename columns, if applicable. For mysql, prefer using the new RENAME COLUMN syntax over the old CHANGE COLUMN syntax.
-- DRIVER: mysql
ALTER TABLE my_table
RENAME COLUMN old_column TO new_column;
-- DRIVER: pgx
ALTER TABLE my_table
RENAME COLUMN old_column TO new_column;
-- DRIVER: mssql
EXEC sp_rename 'my_table.old_column', 'new_column', 'COLUMN';
Refer to the older .sql migration files to identify what if any indices were associated with renamed columns. Append statements to the migration script to rename these indices, if applicable.
-- DRIVER: mysql
ALTER TABLE my_table RENAME INDEX my_table_idx_old_column TO my_table_idx_new_column;
-- DRIVER: pgx
ALTER INDEX my_table_idx_old_column RENAME TO my_table_idx_new_column;
-- DRIVER: mssql
EXEC sp_rename 'my_table_idx_old_column', 'my_table_idx_new_column', 'INDEX';
Update the mappings of the modified database column names to their corresponding object fields in mapColumnsOnInsert, mapColumnsOnUpdate and mapColumnsOnSelect in service.go.
Adjust the query conditions and searchable columns in prepareWhereClauses in service.go that correspond to the changed fields or columns.
Adjust references to the changed fields in service_test.go, including in the NewObject constructor and TestMyNoun_ColumnMappings.
Adjust references to the changed fields in mynounapi/object_test.go and mynounapi/query_test.go.
Follow the housekeeping skill. Modifying fields changes only the hand-written domain code (object.go, query.go, service.go, resources/sql), not definition.go, so the boilerplate regeneration is a no-op; the Version bump and go vet still apply.
TRIGGER when the user asks to upgrade the project to a newer or the latest version of Microbus, or to update the framework. Each Microbus release ships this one self-contained skill; it applies that release's single-version migration, then chains to the next release's copy of this skill until the target version is reached.
TRIGGER when user asks to create, scaffold, or initialize a new microservice.
How to choose the hostname of a new Microbus microservice. Referenced by the add-microservice and add-sql-microservice scaffolding skills (and, through their delegation to add-microservice, by add-python-microservice and import-openapi-microservice). Consult it whenever a microservice's hostname is being chosen.
Performs an architectural review of a microservice-based system built on the Microbus framework. Covers only cross-cutting, cross-microservice concerns - service boundaries, the dependency graph, coupling, cross-service consistency, data ownership, workflow composition, edge security, and system operations. Anything judgeable inside a single microservice directory belongs to the review-microservice skill and is out of scope here. Produces a structured report with findings and recommendations.
Reviews the microservices touched by a set of changes - by default the whole current feature branch versus its merge-base with main, plus any uncommitted work. Runs the review-microservice skill on each changed microservice and the review-architecture skill scoped to those microservices and their graph neighbors, then consolidates one report. Use before merging a branch or before committing working-tree changes.
Performs a thorough review of a single Microbus microservice. Checks for completeness, framework compliance, code quality, security, test coverage, documentation, API design, and data access performance. Produces a structured report with findings and recommendations.