colibri-fw/migration

Colibri Migration component

dev-master 2020-11-10 21:15 UTC

This package is auto-updated.

Last update: 2024-04-11 04:13:39 UTC


README

Usage without framework

  • Install the package:

    composer require colibri-fw/migration
  • Create migration file in root folder of your project with the following contents:

     #!/usr/bin/env php
     <?php
     require_once './vendor/autoload.php';
     
     use Colibri\Config\Config;
     
     Config::setBaseDir(__DIR__ . '/configs'); // <-- path to configs folder in your project
     
     require './vendor/colibri-fw/migration/bin/migration';

    and change configs folder to yours one.

  • Make it executable:

     chmod +x ./migration
    
  • In your configs folder create database.php file to configure your connection

     <?php
     
     use Colibri\Database\Type as DbType;
     
     return [
         'connection' => [
             'default' => 'mysql',
             'mysql'   => [
                 'type'       => DbType::MYSQL,
                 'host'       => 'localhost',
                 'database'   => 'database_name',
                 'user'       => 'user',
                 'password'   => 'password',
                 'persistent' => false,
             ],
         ],
     ];
  • In your configs folder create migration.php file to configure migrations:

     <?php
     
     return [
         /**
          * Name of the table where to store executed migrations.
          */
         'table'     => 'migration',
     
         /**
          * Folder where all migration classes lives.
          */
         'folder'    => __DIR__ . '/../App/Migration',    // <-- Change to yours one
    
         /**
          * Namespace where all migration classes lives.
          */
         'namespace' => 'App\Migration',                  // <-- Change to yours one
     ];