Go Migration Scaffolder
This skill streamlines the workflow for modifying the database schema and adding queries in this project.
Capabilities
- •Scaffolds new database migrations (
postgres/migrations/) - •Scaffolds new query files (
postgres/queries/) - •Automates the
makecommands for creating and applying migrations
Usage
1. Scaffold Migration and Query Files
Run the create-migration.ts script to generate the necessary files.
bash
npx tsx .github/skills/go-migration-scaffolder/scripts/create-migration.ts <migration_name>
Example:
bash
npx tsx .github/skills/go-migration-scaffolder/scripts/create-migration.ts add_products_table
This will:
- •Run
make migrate-create name=add_products_table - •Create a corresponding empty query file:
postgres/queries/products.sql(if it doesn't exist) - •Output the paths of the created files.
2. Implement SQL (Agent Task)
After running the script, the Agent (you) should:
- •Edit the
.up.sqlfile: Add the DDL (CREATE TABLE, ALTER TABLE, etc.) based on the user's request. - •Edit the
.down.sqlfile: Add the DDL to revert the changes (DROP TABLE, etc.). This is critical for rollbacks. - •Edit the
queries/*.sqlfile: Add the necessary queries (formatted for sqlc).sql-- name: CreateProduct :one INSERT INTO products (...) VALUES (...) RETURNING *;
3. Apply and Generate
Once the SQL is written, run:
bash
make migrate-up && make sqlc-gen