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

database-migrations

Skill0 starsChanged 6 months agoMITView on GitHub

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

52 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.
  • royaluniondesign-sysSkill

    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

  • nek1987Skill

    postgres-patterns

    PostgreSQL patterns for reviewing migrations and writing efficient queries. Use when reviewing Alembic migrations, optimizing queries, or debugging database issues.

    Also in 7 projects that use this

  • nek1987Skill

    redis-patterns

    Upstash Redis patterns for caching and rate limiting.

    Also in 3 projects that use this

  • HABUBUSSSkill

    backend-patterns

    Backend architecture patterns, API design, database optimization, and server-side best practices for Node.js, Express, and Next.js API routes.

    Also in 9 projects that use this

  • seikaikyoSkill

    fastapi-patterns

    FastAPI + SQLModel + Neon PostgreSQL 後端開發最佳實踐。適用於 Render 部署的 API 服務。涵蓋路由設計、資料庫操作、錯誤處理、認證授權。

    Also in 3 projects that use this

  • SentrySkill

    react-testing

    Write and review React/TypeScript tests for Sentry's frontend using Jest and React Testing Library. Use when adding or editing tests in static/ (*.spec.tsx), writing component/hook tests, mocking API responses with MockApiClient, testing routing or network requests, or when asked to "write a frontend test", "add a React test", "test this component", or "fix a flaky RTL test".

    Also in 3 projects that use this

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 48 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 48 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.