db-migration-scripts

Writes paired PostgreSQL and SQLite migration SQL scripts for Golem service schemas.

1.5k|212|Updated Nov 24, 2023
One-click install
npx skills add https://github.com/golemcloud/golem --skill db-migration-scripts
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: db-migration-scripts
Source: https://github.com/golemcloud/golem/tree/main/.agents/skills/db-migration-scripts
Command: npx skills add https://github.com/golemcloud/golem --skill db-migration-scripts

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Writing database migrations in the Golem repository requires keeping PostgreSQL and SQLite schemas in sync across multiple migration roots, each with its own naming and style conventions. This Skill encodes those rules so new migration files land in the right directory with the right numbering, types, and index names.

Core Features & Use Cases

  • Dual-engine migrations: Creates matching PostgreSQL and SQLite migration files with the same numbered prefix, choosing shared or divergent schema shapes based on the owning root's query layer.
  • Convention enforcement: Applies per-root index and constraint naming (<table>_<column>_idx/_uk vs idx_ prefix), sequential three-digit file numbering, and local DDL style.
  • No compatibility layer: Directs schema changes to be made directly, updating in-tree queries and models in the same change without dual-read/dual-write or legacy columns.
  • Use Case: When adding a new table to the registry service, the Skill places 004_new_table.sql in both golem-registry-service/db/migration/postgres/ and .../sqlite/ with converged column types and matching constraint names, then points to the repository tests that verify both backends.

Quick Start

Ask the AI to create a new database migration adding a table or column to one of the Golem services, and it will generate the paired PostgreSQL and SQLite SQL files following the owning root's conventions.

Frequently Asked Questions about db-migration-scripts

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a database migration in the Golem repository?

Create matching SQL files in the owning service's db/migration/postgres and db/migration/sqlite directories with the same sequential three-digit prefix. Read neighboring migrations first to match types, constraint names, and DDL style for that root.

Do Golem migrations need to support both PostgreSQL and SQLite?

Yes, every schema change must be implemented for both engines with matching filenames. Shared-query roots like the registry service should converge on one schema shape, while worker-executor roots with per-engine query layers may diverge.

What naming convention do Golem migration indexes use?

The registry service and shard manager use <table>_<column>_idx for indexes, _uk for unique indexes, and <table>_pk for primary keys. The worker-executor keyvalue and indexed roots use an idx_ prefix instead, so match the files you are editing.

Can I use PostgreSQL-specific types like BIGSERIAL in migrations?

Only where there is no common alternative. SQLite's type affinity accepts UUID, TIMESTAMP, BIGINT, BYTEA, and NUMERIC verbatim, so shared-query roots should prefer types that work in both engines and keep the end-state schema identical.

Should migrations include backward-compatibility or dual-write logic?

No. Migrations move the schema forward directly: update all in-tree queries and models in the same change and remove replaced columns or tables. Dual-read/dual-write behavior, legacy columns, and compatibility views are not added.

How are Golem database migrations tested?

Run an affected persistence or repository test against both database variants, since these tests apply migrations to a fresh database before exercising the changed table. PostgreSQL tests use golem-test-framework to provision the database rather than spawning processes directly.