2017 © Pedro Peláez
 

library migrator

Database and config migrations made simple

image

pckg/migrator

Database and config migrations made simple

  • Tuesday, May 22, 2018
  • by schtr4jh
  • Repository
  • 1 Watchers
  • 1 Stars
  • 2,147 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Migrator

Codacy Badge, (*1)

Build status, (*2)

Usage

Register Pckg\Migration\Provider\Migration provider in your application. This is only needed if you don't use Pckg\Framework\Provider\Framework., (*3)

...
use Pckg\Migration\Provider\Migration;
...
public function providers()
{
    return [
        Migration::class,
    ];
}

Consoles

All commands are app-scoped and need to be prefixed with php console $appName., (*4)

migrator:install - Install migrations from environment, (*5)

  • --only=SomeMigration - Install only listed migrations
  • --fields - Install only fields (no indexes/key)
  • --indexes - Install only indexes/key (no fields)
  • --yes - Say yes to all questions
  • --clear - Clear cache before and after
  • --retry=1 - Retry iterations
  • --repository=default - Install only repository

Create a migration

<?php

namespace Foo\Migration;

use Foo\Migration\SomeMigration;

class SomeMigration extends \Pckg\Framework\Provider
{

    public function up()
    {
        $clients = $this->table('clients');
        $clients->deletable();
        $clients->varchar('name');
        $clients->json('props');

        $projects = $this->table('projects');
        $projects->timeable();
        $projects->deletable();
        $projects->integer('client_id')->references('clients');
        $projects->varchar('name');

        $this->save();
    }
}

Apply migration

List your migrations in ./config/migrations.php or ./app/$app/config/migrations.php., (*6)

<?php

use Foo\Migration\SomeMigration;

return [
    SomeMigration::class,
];

Or add your migration to the Provider., (*7)

<?php

namespace Foo\Provider;

use Pckg\Framework\Provider;
use Foo\Migration\SomeMigration;

class Feature extends Provider
{

    public function migrations()
    {
        return [
            SomeMigration::class,
        ];
    }
}

And then execute migrations:, (*8)

# php console $appName migrator:install, (*9)

The Versions

22/05 2018

dev-master

9999999-dev https://github.com/pckg/migrator

Database and config migrations made simple

  Sources   Download

MIT

The Requires

 

by Bojan Rajh

06/02 2017

v0.1.0

0.1.0.0 https://github.com/pckg/migrator

Database, config and other migrations made simple

  Sources   Download

MIT

The Requires

 

by Bojan Rajh