colibri-fw/migration

Colibri Migration component

dev-master 2024-05-21 16:26 UTC

This package is auto-updated.

Last update: 2024-12-21 17:48:41 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
     ];