sebwas/laravel-migration-physical-backup

此包已被弃用且不再维护。未建议替代包。

此简单工具帮助开发者创建正在更改的表的物理备份,允许轻松快速地恢复。

v1.0.3 2016-03-02 11:35 UTC

This package is not auto-updated.

Last update: 2022-02-01 12:55:58 UTC


README

早上好,亲爱的开发者!祝您今天愉快,享受这个小巧的工具。

用法

在迁移中,只需像这样使用 SebWas\Laravel\Migration\PhysicalBackup 特性(示例文件)

<?php

use Illuminate\Database\Schema\Blueprint;
use SebWas\Laravel\Migration\PhysicalBackup;
use Illuminate\Database\Migrations\Migration;

class TestMigration extends Migration
{
	use PhysicalBackup;

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        // Do your stuff here
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
    	$this->runRestore();
		// Either delete this function or use the runRestore method from here
    }
}

工作原理

特性仅设置一个构造函数,它会扫描您的文件以查找表名,并使用 mysqldump 命令行工具创建这些表的备份。它还会覆盖您的 Migration::down() 方法,以便自动从它创建的备份文件中重建。

限制

目前,此工具依赖于mysql的使用、命令行界面以及文件系统访问。您可以自由地为此项目做出贡献,提供其他数据库或其他创建和存储备份的方法。(例如,创建一个表并使用原始查询或您能想到的任何其他方法。)