承接 cubadevops/dbmigrator 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

cubadevops/dbmigrator

最新稳定版本:1.0.1

Composer 安装命令:

composer require cubadevops/dbmigrator

包简介

Simple PHP Version Control(migration system) for databases

README 文档

README

Simple Control Version System for Databases

How to Integrate on your Project or in a single module/plugin directory inside your project

First require autoload.php

require_once './vendor/autoload.php';

Then configure the connection to your database

$connection = new Connection('localhost', '3306', 'root', 'root', 'test', 'mysql');

Configure your migration path and the name of the migrations version table

$configurator = new Configurator($connection, __DIR__.'/migrations_dir', 'migrations_version_table');

Finally create the migrator manager

$migrator = new Migrator($configurator);

How to use

First you must create a migration class that extend of Migration or just implement Migration interface if you use a simple plain query inside "up" and "down" methods

use CubaDevOps\DbMigrator\domain\Migration;
use Illuminate\Database\Capsule\Manager;
use Illuminate\Database\Schema\Blueprint;

class MigrationTest extends Migration
{

    public function up(): void
    {
        Manager::schema()->create('migration_example_table',function (Blueprint $table){
            $table->increments('id');
            $table->string('content')->default('test');
            // others columns
        });
    }

    public function down(): void
    {
        Manager::schema()->dropIfExists('migration_example_table');
    }
}

How to Run Pending migrations

$migrator->migrate();

How rollback migrations

$migrator->rollback();

How to Run a Fresh version of your entire migrations

$migrator->fresh();

This is the same that do:

$migrator->rollback(); and then $migrator->migrate();

You are welcome to contribute to this project with new features or bug fixes, just make a "pull request" on a new branch.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-10-01

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固