vakata/migrations 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

vakata/migrations

最新稳定版本:1.1.2

Composer 安装命令:

composer require vakata/migrations

包简介

PHP database migrations

README 文档

README

Latest Version on Packagist Software License

PHP database migrations.

Install

Via Composer

$ composer require vakata/migrations

Usage

Prepare a directory for all migrations. A migration consists of a folder with 3 files inside:

  • schema.sql - needed schema modifications
  • data.sql - optional data to insert / update / delete
  • uninstall.sql - optional statements to fully revert this migration

Example structure:

 |-migrations
   |- base
   |  |- _core
   |     |- 000
   |        |- schema.sql
   |        |- data.sql
   |        |- uninstall.sql
   |- app
      |- feature1
      |  |- 000
      |  |  |- schema.sql
      |  |  |- data.sql
      |  |  |- uninstall.sql
      |  |- 001
      |     |- schema.sql
      |- feature2
         |- 000
            |- schema.sql
            |- uninstall.sql

Create the neccessary table, for example:

-- postgre
CREATE TABLE IF NOT EXISTS migrations (
  migration SERIAL NOT NULL,
  package varchar(255) NOT NULL,
  installed timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ,
  removed timestamp DEFAULT NULL ,
  PRIMARY KEY (migration)
);
-- mysql
CREATE TABLE IF NOT EXISTS migrations (
  migration bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  package varchar(255) COLLATE utf8mb4_general_ci NOT NULL,
  installed datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  removed datetime DEFAULT NULL,
  PRIMARY KEY (migration)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ;
$migrations = new \vakata\migrations\Migrations(
    new \vakata\database\DB('<connection-string-here>'),
    'path/to/migrations/folder',
    [ 'base/', 'app/feature2', 'app' ] // optional feature flags (also used for sorting)
    null // optional sort callback
);
// this will install the packages in this order:
// base/_core/000, app/feature2/000, app/feature1/000, app/feature1/000
$migrations->up();

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email github@vakata.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 1.64k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-12-05