Download the PHP package rkr/php-db-migrations without Composer
On this page you can find all versions of the php package rkr/php-db-migrations. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download rkr/php-db-migrations
More information about rkr/php-db-migrations
Files in rkr/php-db-migrations
Package php-db-migrations
Short Description Not yet powerful library to execute db-migration files
License MIT
Homepage https://github.com/rkrx/db-migrations
Informations about the package php-db-migrations
db-migrations
Lightweight library to execute ordered DB migration files.
Features
- Sequential execution with automatic rollback of previous steps when a step fails.
- Supports plain SQL and fluent migration builders.
- Fluent migrations derive DOWN steps from the current schema.
- Strict feature gating per engine/version (unsupported required features abort the migration with an exception).
Basic usage
MigrationManager with PdoDBAdapter
Adapters
PdoDBAdapteruses the built-in SQL renderer/inspector (MySQL/MariaDB/SQLite).DoctrineDbalAdapteruses Doctrine DBAL as platform + schema layer (MySQL/MariaDB/PostgreSQL/SQLite/MSSQL/Oracle via DBAL).
Example with Doctrine DBAL:
Supported Databases and Adapter Trade-offs
Supported with PdoDBAdapter:
- MySQL (8+)
- MariaDB (10.6+)
- SQLite (limited set of operations)
Supported with DoctrineDbalAdapter (via DBAL platforms):
- MySQL (8+)
- MariaDB (10.6+)
- PostgreSQL (12+)
- SQLite
- MSSQL
- Oracle
Why choose which adapter:
PdoDBAdapter: Simple, direct SQL path, no DBAL dependency, fast for MySQL/MariaDB/SQLite.DoctrineDbalAdapter: Uses DBAL schema/platform abstractions, better cross-DBMS portability and DDL generation.
DBAL Test Environment
Integration tests for the DBAL adapter read the following environment variables:
TEST_DB_MYSQL_DSNTEST_DB_MARIADB_DSNTEST_DB_PG_DSN
Use .env.local.example as a starting point for local development and provide the same variables in CI.
.env.local is optional for local runs; without it, DBAL integration tests will be skipped.
GitHub Actions runs the DBAL suite against real databases for SQLite, MySQL, MariaDB, and PostgreSQL.
Fluent usage
Foreign keys + index example
Atomic DDL operations
Each operation generates an UP and derives DOWN from the live schema. Unsupported features are skipped with a warning.
Create/alter/drop tables
Add::table(name: string)Add::toTable(name: string)Drop::table(name: string)Drop::fromTable(name: string)Change::table(name: string)
Columns
column(name, type, nullable = false, default = null, comment = null, charset = null, collation = null, onUpdate = null, autoIncrement = false, isUnsigned = false, after = null, first = false)intColumn(name, length = null, isUnsigned = false, nullable = false, default = null, comment = null, after = null, first = false)bigIntColumn(name, length = null, isUnsigned = false, nullable = false, default = null, comment = null, after = null, first = false)smallIntColumn(name, length = null, isUnsigned = false, nullable = false, default = null, comment = null, after = null, first = false)tinyIntColumn(name, length = null, isUnsigned = false, nullable = false, default = null, comment = null, after = null, first = false)varcharColumn(name, length, nullable = false, default = null, comment = null, charset = null, collation = null, after = null, first = false)charColumn(name, length, nullable = false, default = null, comment = null, charset = null, collation = null, after = null, first = false)textColumn(name, nullable = false, comment = null, after = null, first = false)decimalColumn(name, precision, scale, nullable = false, default = null, comment = null, isUnsigned = false, after = null, first = false)floatColumn(name, nullable = false, default = null, comment = null, isUnsigned = false, after = null, first = false)doubleColumn(name, nullable = false, default = null, comment = null, isUnsigned = false, after = null, first = false)booleanColumn(name, nullable = false, default = null, comment = null, after = null, first = false)dateColumn(name, nullable = false, default = null, comment = null, after = null, first = false)dateTimeColumn(name, nullable = false, default = null, onUpdate = null, comment = null, after = null, first = false)timestampColumn(name, nullable = false, default = null, onUpdate = null, comment = null, after = null, first = false)jsonColumn(name, nullable = false, comment = null, after = null, first = false)
Keys and indexes
primaryKey(...columns)autoIncrement(columnName)index(name, ...columns)uniqueIndex(name, ...columns)foreignKey(name, localColumns, foreignTable, foreignColumns, onUpdate = null, onDelete = null)
Table options
engine(name)charset(name)collation(name)
Engine support
- MariaDB 10.6 and later are supported by default with strict feature detection.
- SQLite is supported for a limited set of operations; unsupported required features abort the migration.
- Unsupported required features throw
UnsupportedFeatureException; incomplete migrations are never recorded as applied. - Doctrine DBAL adapter adds support for PostgreSQL, MSSQL, and Oracle via DBAL platforms.