Download the PHP package marekskopal/orm-migrations without Composer
On this page you can find all versions of the php package marekskopal/orm-migrations. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download marekskopal/orm-migrations
More information about marekskopal/orm-migrations
Files in marekskopal/orm-migrations
Package orm-migrations
Short Description Migrations for MarekSkopal ORM.
License MIT
Informations about the package orm-migrations
ORM Migrations
Database migration library for marekskopal/orm. Automatically generates PHP migration files by comparing your ORM entity schema with the live database schema.
Supports MySQL and PostgreSQL.
Installation
This version requires marekskopal/orm 2.x. For marekskopal/orm 1.x, use marekskopal/orm-migrations 1.x.
Usage
Setup
For PostgreSQL, use PostgresDatabase instead of MySqlDatabase — no other changes needed.
A schema dumped with SchemaBuilder::dump() works too: pass Schema::fromFile($path) to generate().
An optional PSR-3 LoggerInterface can be passed as the third argument to Migrator to log migration execution.
Generate a migration
This compares the ORM entity schema against the live database and writes a new PHP migration file to the configured path. Only actual differences (added/changed/removed tables, columns, indexes, foreign keys) are included.
A foreign key column takes the type of the primary key it references, so a relation to an entity with a UUID or string key gets a matching column.
Example generated file:
Run migrations
Executes all pending migrations in order. Completed migrations are tracked in a __migrations table in the database. Afterwards the database's statement cache is cleared, since statements the ORM prepared on the same connection may refer to tables the migrations changed.
TableBuilder API
Inside up() and down(), use $this->table(string $name) to get a TableBuilder. All methods are fluent and support both Type enum values and their string names.
Column operations
Index operations
Foreign key operations
Insert data
Available column types
Type enum |
MySQL | PostgreSQL |
|---|---|---|
Type::SmallInt |
smallint |
smallint |
Type::Int |
int |
integer |
Type::BigInt |
bigint |
bigint |
Type::Decimal |
decimal |
decimal |
Type::Float |
float |
real |
Type::Double |
double precision |
double precision |
Type::String |
varchar |
varchar |
Type::Text |
text |
text |
Type::Boolean |
tinyint(1) |
boolean |
Type::Uuid |
uuid |
uuid |
Type::Date |
date |
date |
Type::DateTime |
datetime |
timestamp |
Type::Timestamp |
timestamp |
timestamptz |
Type::Json |
json |
json |
Type::Enum |
enum(...) |
varchar + CHECK |
Migration file naming
Generated files use a Ymd_His_ timestamp prefix (e.g. 20240101_120000_CreateUserTable.php). Migrations are executed in filename order, so this ensures correct sequencing even across branches.
License
MIT
All versions of orm-migrations with dependencies
marekskopal/orm Version ^2.0
nette/php-generator Version ^4.1
psr/log Version ^3.0