colibri-fw/migration

Colibri 迁移组件

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

This package is auto-updated.

Last update: 2024-09-21 17:11:24 UTC


README

不使用框架的用法

  • 安装包

    composer require colibri-fw/migration
  • 在项目的根目录中创建一个名为 migration 的文件,内容如下

     #!/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';

    并将配置文件夹更改为您的配置文件夹。

  • 使其可执行

     chmod +x ./migration
    
  • 在您的配置文件夹中创建一个 database.php 文件以配置连接

     <?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,
             ],
         ],
     ];
  • 在您的配置文件夹中创建一个 migration.php 文件以配置迁移

     <?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
     ];