Rowcast Schema

Schema-first migration toolkit for PDO databases, friendly to Rowcast.

CI codecov PHPStan Level 9 Latest Stable Version PHP Version License

Get Started Русский View on GitHub


What is Rowcast Schema?

Rowcast Schema is a schema-first migration toolkit for PHP 8.4+. Define your database structure in a PHP or YAML file, compare it against a live database, and automatically generate PHP migration classes with up() and down() methods.

Key Highlights

  • Schema-first — define your tables, columns, indexes, and foreign keys in schema.php or schema.yaml
  • Auto diff — compare schema against a live database and generate migrations automatically
  • Zero required dependencies — only PHP 8.4 and ext-pdo; YAML support is optional via symfony/yaml
  • Multi-database — MySQL, PostgreSQL, and SQLite support out of the box
  • SQLite rebuild pipeline — automatically handles complex DDL changes that SQLite can’t do natively
  • Fluent migration API — generated migrations use a clean SchemaBuilder with up() / down()
  • PHPStan Level 9 — fully statically analyzed codebase
  • Friendly to Rowcast — shares PDO connection, follows the same conventions

Quick Example

Define your schema in schema.php:

<?php

return [
    'tables' => [
        'users' => [
            'columns' => [
                'id' => ['type' => 'integer', 'primaryKey' => true, 'autoIncrement' => true],
                'email' => ['type' => 'string', 'length' => 255],
                'created_at' => ['type' => 'datetime', 'default' => 'CURRENT_TIMESTAMP'],
            ],
            'indexes' => [
                'idx_users_email' => ['columns' => ['email'], 'unique' => true],
            ],
        ],
    ],
];

Then generate and apply migrations:

vendor/bin/rowcast-schema diff      # generate migration from schema changes
vendor/bin/rowcast-schema migrate   # apply pending migrations
vendor/bin/rowcast-schema status    # check sync status

Requirements

  • PHP >= 8.4
  • PDO extension

Installation

composer require ascetic-soft/rowcast-schema

Documentation

Getting Started

Installation, configuration, and first migration in 5 minutes.

Schema Definition

PHP and YAML schema formats, column types, indexes, and foreign keys.

CLI Commands

diff, migrate, rollback, and status commands.

Migrations

Generated migration format, SchemaBuilder API, and migration runner.

SQLite Support

Rebuild pipeline for complex DDL changes on SQLite.

API Reference

Complete reference for all public classes and interfaces.