Download the PHP package turanct/migraine without Composer
On this page you can find all versions of the php package turanct/migraine. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package migraine
🤯 Migraine
A simple way of providing database migrations to your project
Disclaimer
Use this package at your own risk.
Goals
- [x] Write migrations as simple SQL statements
- [x] Be framework agnostic
- [x] Run migrations on multiple databases
- [x] Run different migrations on different groups of databases
- [x] Allow seeding of the databases
- [x] Keep logs in SQL itself
- [ ] Have the ability to roll back migrations
Usage
Install using Composer
Provide a config file
In this example we have two groups, main which is the main database, and shards which is a group of sharded databases. The difference between main and shards (in production) is that shards contains of multiple databases which all need to look the same. This means that if we do a migration, we'll run it on all those databases.
migrations.json
By default, migraine will log the migrations that are done in logs.json in your working directory, however this is configurable:
Logging in a different file
migrations.json
Logging in SQL
migrations.json
Prepare your migrations directory
Add some migrations
You can use the new command to create a new migration:
it will create this file:
migrations/main/20200426195623000-create-users-table.sql
We'll fill it with the migration we want to run:
and this command for the shards:
will create this file:
migrations/shards/20200426195959000-create-data-table.sql
We'll fill it with the migration we want to run:
Run the migrations
This is how you run all migrations. We'll automatically dry-run your migration:
If you want to commit to the migration you just did a dry-run for, commit:
If you want to only migrate a given group, specify it:
If you want to only run a specific migration, specify it:
If you want to skip a migration (e.g. because you know it was already done manually):
Use the skip functionality with caution. It writes a skipped log to the log file, and will never run this migration again, just like the migration was actually executed.
Seeding
You can create seeds by adding a /seeds directory to a group's directory.
In that directory, you can add files just like any other migration.
it will create this file:
migrations/main/seeds/20200426195623000-seed-users.sql
Fill it with the migration you want to run:
If you want to apply a specific seed, specify it
Contributing
Please see CODE_OF_CONDUCT for details.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
License
The MIT License (MIT). Please see License File for more information.
All versions of migraine with dependencies
ext-json Version *
ext-pdo Version *
symfony/finder Version ^v4.4.8
symfony/console Version ^v4.4.7