agentsclimarketplace

Database migrations

Skill ColdBox/skills/coldbox/database-migrations

Use this skill when managing database schema changes in ColdBox/BoxLang using cfmigrations and commandbox-migrations. Covers migration file structure, Schema Builder API, seeding, and CLI workflows for creating, running, and rolling back migrations safely.From its SKILL.md

Install
npx -y skills add ColdBox/skills --skill database-migrations

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

2 things to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

3.0 KB, 646 tokens by cl100k_base, as published. Nobody here has run it

Database Migrations Skill

When to Use This Skill

Load this skill when:

  • Creating or altering schema with versioned migration files
  • Writing migration up()/down() logic with Schema Builder
  • Running migrations from CommandBox in local/dev/CI pipelines
  • Seeding baseline or test data
  • Rolling back schema changes safely

Installation

box install commandbox-migrations

Core Configuration

config/ColdBox.cfc

moduleSettings = {
    cfmigrations: {
        manager:             "cfmigrations.models.QBMigrationManager",
        migrationsDirectory: "/resources/database/migrations/",
        seedsDirectory:      "/resources/database/seeds/",
        properties: {
            defaultGrammar: "MySQLGrammar@qb",
            datasource:     "appDB"
        }
    }
}

Optional .cfmigrations

{
  "default": {
    "driver": "MySQL",
    "host": "${DB_HOST}",
    "port": "${DB_PORT:3306}",
    "database": "${DB_DATABASE}",
    "username": "${DB_USERNAME}",
    "password": "${DB_PASSWORD}",
    "migrationsTable": "cfmigrations",
    "migrationsDirectory": "resources/database/migrations"
  }
}

CLI Workflow

# One-time setup
box migrate install

# Create migration
box migrate create create_users_table

# Run / rollback
box migrate up
box migrate down
box migrate reset
box migrate refresh

# Seed and inspect
box migrate seed
box migrate status

Migration Shape

component {
    function up( schema, query ) {
        schema.create( "users", ( table ) => {
            table.increments( "id" )
            table.string( "email" ).unique()
            table.string( "password" )
            table.boolean( "isActive" ).default( true )
            table.timestamps()
        } )
    }

    function down( schema, query ) {
        schema.drop( "users" )
    }
}

Common Schema Operations

schema.create( "posts", ( table ) => {
    table.increments( "id" )
    table.unsignedInteger( "userId" )
    table.string( "title" )
    table.longText( "body" ).nullable()
    table.timestamps()

    table.index( "userId" )
    table.foreignKey( "userId" ).references( "id" ).onTable( "users" ).onDelete( "CASCADE" )
} )

schema.alter( "posts", ( table ) => {
    table.addColumn( table.string( "slug" ).unique() )
    table.renameColumn( "body", "content" )
} )

Best Practices

  • Use one logical change per migration
  • Always implement down() and verify rollback locally
  • Never edit deployed migrations; add a new migration instead
  • Use env vars for credentials and avoid destructive commands in production
  • Use box migrate up (not reset/refresh) in production deployments

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.