aim-database-migration

Enforce idempotent AIM PostgreSQL migration conventions with numbered SQL files and sqlc generate verification.

4|Updated May 17, 2026
One-click install
npx skills add https://github.com/hellopoisonx/aim --skill aim-database-migration
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: aim-database-migration
Source: https://github.com/hellopoisonx/aim/tree/main/skills/aim-database-migration
Command: npx skills add https://github.com/hellopoisonx/aim --skill aim-database-migration

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

It prevents failed AIM database migrations and broken local deployments by enforcing a repeatable, deterministic PostgreSQL migration workflow for the auth and logic domains.

Core Features & Use Cases

  • Idempotent DDL enforcement: ensures CREATE/ALTER statements can run multiple times without “already exists” failures, especially when Docker volumes cause migrate containers to re-run.
  • Deterministic migration ordering: mandates NNN_description.sql naming so migrations execute in correct dictionary order via the compose migrate init container.
  • End-to-end validation: requires running sqlc generate and go test after adding or changing migration SQL to keep generated models consistent.

Quick Start

When you modify or add a migration SQL file, run sqlc generation and then execute go tests for the affected domain packages to confirm the new schema and queries work correctly.

Frequently Asked Questions about aim-database-migration

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

FAQPage Schema
How do I make PostgreSQL migrations idempotent so Docker Compose re-runs don't fail?

To make PostgreSQL migrations idempotent, use IF NOT EXISTS clauses in CREATE and ALTER statements. This prevents Docker Compose migrate containers from throwing already exists errors when volumes cause re-runs.

Why does my Docker Compose migrate container fail when adding a new PostgreSQL schema file?

Docker Compose migrate containers fail when PostgreSQL schema files lack deterministic ordering or explicit database creation. Ensure files use NNN_description.sql naming and deploy/scripts/migrate-postgres.sh explicitly creates the database.

What's the best way to validate SQLC queries after changing a PostgreSQL migration file?

The best way to validate SQLC queries after changing PostgreSQL migration files is running sqlc generate followed by go test. This confirms generated models match the updated schema and queries work correctly.

Do I need to regenerate SQLC models every time I add a PostgreSQL migration script?

Yes, you need to regenerate SQLC models every time you add a PostgreSQL migration script. Running sqlc generate after schema updates keeps generated query models consistent with the new database structure.

How do I enforce deterministic migration ordering for PostgreSQL schema updates?

To enforce deterministic migration ordering for PostgreSQL schema updates, mandate NNN_description.sql filename patterns. This ensures the compose migrate init container executes scripts in correct dictionary order reliably.

Can I use non-idempotent DDL patterns in PostgreSQL migrations managed by Docker Compose?

No, you cannot safely use non-idempotent DDL patterns in PostgreSQL migrations managed by Docker Compose. Idempotent DDL patterns like IF NOT EXISTS are required to prevent failures when migrate containers re-run.