agentleFS
ci4meci4me/CQRSTemplate/.agents/skills/database-migrations/SKILL.md

database-migrations

Skill0 starsChanged 7 months agoMITView on GitHub

Create and run database migrations in the CQRSTemplate repo. Use when adding tables, columns, or modifying schema.

33 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use deployment-patterns, postgres-patterns and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • InfopibeSkill

    deployment-patterns

    Deployment workflows, CI/CD pipeline patterns, Docker containerization, health checks, rollback strategies, and production readiness checklists for web applications.

    Also in 6 projects that use this

  • joneqianSkill

    postgres-patterns

    PostgreSQL database patterns for query optimization, schema design, indexing, and security. Based on Supabase best practices.

    Also in 5 projects that use this

  • devsforgeSkill

    backend-patterns

    Expert knowledge in API design, authentication, caching, and backend best practices. Use for backend development tasks.

    Also in 8 projects that use this

  • InfopibeSkill

    autonomous-loops

    Patterns and architectures for autonomous Claude Code loops — from simple sequential pipelines to RFC-driven multi-agent DAG systems.

    Also in 3 projects that use this

  • Svenja-devSkill

    e2e-testing

    Also in 6 projects that use this

  • xfstudioSkill

    python-patterns

    Python development principles and decision-making. Framework selection, async patterns, type hints, project structure. Teaches thinking, not copying.

    Also in 4 projects that use this

  • +1 more from Infopibe

The file

We split this skill into the rules it gives an agent

6 rules. 0 are common, 1 is distinctive, and 5 are very specific to this project.

  • 0

    Common

    Most of the 30 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 5

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use addField with explicit type constraints

    line 84
  2. Very specific:

    Always include created_at, updated_at, deleted_at for domain tables

    line 85
  3. Very specific:

    Use unsigned for ID fields

    line 86
  4. Very specific:

    Check fieldExists() in up() for idempotent column additions

    line 87
  5. Distinctive:

    If adding a property to a domain entity, follow the property-addition skill

    line 93
  6. Very specific:

    Run composer check to verify nothing breaks

    line 94

“Common” is measured: kept by at least 6 in 10 of the 30 edited versions of this file we could read. “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 Migrations

Creating a Migration

php spark make:migration <MigrationName>

This creates a file in app/Database/Migrations/ with a timestamp prefix.

Migration File Structure

<?php

declare(strict_types=1);

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class CreateOrdersTable extends Migration
{
    public function up(): void
    {
        $this->forge->addField([
            'id' => [
                'type' => 'INT',
                'constraint' => 11,
                'unsigned' => true,
                'auto_increment' => true,
            ],
            // ... fields ...
            'created_at' => ['type' => 'DATETIME', 'null' => false],
            'updated_at' => ['type' => 'DATETIME', 'null' => true],
            'deleted_at' => ['type' => 'DATETIME', 'null' => true],
        ]);
        $this->forge->addKey('id', true);
        $this->forge->createTable('orders');
    }

    public function down(): void
    {
        $this->forge->dropTable('orders');
    }
}

Adding a Column to an Existing Table

public function up(): void
{
    if ($this->db->fieldExists('column_name', 'table_name')) {
        return;
    }
    $this->forge->addColumn('table_name', [
        'column_name' => [
            'type' => 'VARCHAR',
            'constraint' => 100,
            'null' => true,
            'after' => 'existing_column',
        ],
    ]);
}

Running Migrations

php spark migrate --all    # Run all namespaced migrations
php spark migrate:rollback # Rollback last batch
php spark migrate:status   # Check migration status

Conventions

  • Always use declare(strict_types=1)
  • Use addField with explicit type constraints
  • Always include created_at, updated_at, deleted_at for domain tables
  • Use unsigned for ID fields
  • Check fieldExists() in up() for idempotent column additions
  • Naming: Create<Table>Table, Add<Column>To<Table>Table

After Creating a Migration

  1. Run: php spark migrate --all
  2. If adding a property to a domain entity, follow the property-addition skill
  3. Run composer check to verify nothing breaks

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.