agentleFS
agentsdanceagentsdance/agentskills/skills/database-migration-generator/SKILL.md

database-migration-generator

Skill3 starsChanged 11 months agoApache-2.0View on GitHub

Generate database migration files. Use when the user needs to create schema changes, add tables, modify columns, or manage database versions.

  • Deletes or force-pushes

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 5 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈5

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Create and manage database schema migrations.

    line 8
  2. Distinctive:

    Always create both up and down migrations

    line 101
  3. Distinctive:

    Test migrations on a copy of production data

    line 102
  4. Distinctive:

    Keep migrations small and focused

    line 103
  5. Distinctive:

    Never modify a migration after it's been applied

    line 104

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Database Migration Generator

Create and manage database schema migrations.

Migration Frameworks

FrameworkLanguageCommand
PrismaTypeScriptnpx prisma migrate dev
KnexJavaScriptnpx knex migrate:make
AlembicPythonalembic revision
GooseGogoose create
RailsRubyrails generate migration

Prisma Migration

// schema.prisma
model User {
  id        Int      @id @default(autoincrement())
  email     String   @unique
  name      String?
  posts     Post[]
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
}

model Post {
  id        Int      @id @default(autoincrement())
  title     String
  content   String?
  published Boolean  @default(false)
  authorId  Int
  author    User     @relation(fields: [authorId], references: [id])
}

Raw SQL Migration

-- migrations/001_create_users.up.sql
CREATE TABLE users (
    id SERIAL PRIMARY KEY,
    email VARCHAR(255) UNIQUE NOT NULL,
    name VARCHAR(255),
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

CREATE INDEX idx_users_email ON users(email);

-- migrations/001_create_users.down.sql
DROP TABLE IF EXISTS users;

Knex Migration

// migrations/20240115_create_users.js
exports.up = function(knex) {
  return knex.schema.createTable('users', (table) => {
    table.increments('id').primary();
    table.string('email').unique().notNullable();
    table.string('name');
    table.timestamps(true, true);
  });
};

exports.down = function(knex) {
  return knex.schema.dropTable('users');
};

Common Operations

-- Add column
ALTER TABLE users ADD COLUMN phone VARCHAR(20);

-- Rename column
ALTER TABLE users RENAME COLUMN name TO full_name;

-- Change column type
ALTER TABLE users ALTER COLUMN phone TYPE VARCHAR(50);

-- Add index
CREATE INDEX idx_users_name ON users(full_name);

-- Add foreign key
ALTER TABLE posts ADD CONSTRAINT fk_author
  FOREIGN KEY (author_id) REFERENCES users(id);

Best Practices

  • Always create both up and down migrations
  • Test migrations on a copy of production data
  • Keep migrations small and focused
  • Never modify a migration after it's been applied

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.