evopix / minion-database
Database migration and seeder for Kohana's Minion task runner.
Installs: 6
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 1
Open Issues: 0
Type:kohana-module
Requires
- php: >=5.4.0
- composer/installers: ~1.0
- evopix/kohana-schema: *
This package is not auto-updated.
Last update: 2020-01-24 14:53:28 UTC
README
Introduction
The Minion Database module provides a database agnostic way of modifying the database schema and staying up to date on the current schema state.
Creating Migrations
To create a migration, you may use the migration:make
task on the Minion CLI:
minion migration:make --group=foo
The migration will be placed in the application/database/migrations/foo
directory, and the file name will be a timestamp.
You may also specify a --description
option when creating a migration to provide context. The description will be appended to the migration filename and included in the migration class comment.
minion migration:make --group=foo --description="Creating foo table"
Running Migrations
Running all required migrations:
minion db:migrate
Running all required migrations for a specific group:
minion db:migrate --group=foo
Running all required migrations for a multiple groups:
minion db:migrate --group=foo,bar
Running a specific migration:
minion db:migrate --to=20140327143111
Running the next n
migrations:
minion db:migrate --to=+3
Rolling Back Migrations
Rolling back the last migration:
minion db:migrate --to=-1
Rolling back to a specific migration:
minion db:migrate --to=20140327143111
Rolling back the last n
migrations:
minion db:migrate --to=-3
Database Seeding
This module also includes a simple way to seed your database with test data using seed classes. All seed classes are stored in application/database/seeds
. Seed classes are split into groups just like migrations and may have any name you wish, but probably should follow some sensible convention, such as UserTableSeeder, etc. A DatabaseSeeder class is required for each group and it's from this class that you may use the call method to run other seed classes, allowing you to control the seeding order.
To seed your database, you may use the db:seed command on the Artisan CLI:
minion db:seed
You may also specify a single group or multiple groups to seed:
minion db:seed --group=foo
minion db:seed --group=foo,bar