| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- <?php
- use Illuminate\Database\Migrations\Migration;
- use Illuminate\Database\Schema\Blueprint;
- use Illuminate\Support\Facades\Schema;
- class ChangePriceModelTable extends Migration
- {
- protected $tables = ["owner_storage_price_models","owner_price_operations","owner_price_logistics","owner_price_expresses","owner_price_direct_logistics"];
- /**
- * Run the migrations.
- *
- * @return void
- */
- public function up()
- {
- foreach ($this->tables as $table){
- Schema::table($table,function (Blueprint $table){
- $table->char("operation",1)->index()->nullable()->comment("操作类型");
- $table->bigInteger("target_id")->index()->nullable()->comment("目标ID");
- });
- }
- }
- /**
- * Reverse the migrations.
- *
- * @return void
- */
- public function down()
- {
- foreach ($this->tables as $table){
- Schema::table($table,function (Blueprint $table){
- $table->dropColumn("operation",1);
- $table->dropColumn("target_id");
- });
- }
- }
- /*TODO 可回滚数据功能:1.增加两个字段 operation(哪种类型操作) target_id(映射目标)
- 2.新增操作:未审核时增加operation为C
- 修改前提,对应的映射目标不可被查看修改
- 3.修改操作:当前修改对象是否为被标记过对象,是->直接修改当前对象 否->生成标记对象
- 3.删除操作:当前删除对象是否为被标记过对象,是->目标是否存在(是->删除当前对象,将目标对象标记为删除 否->将当前对象标记为删除) 否->将当前对象标记为删除
- 审核操作:被标记为C的删除标记信息 被标记为U的删除目标对象与当前对象的标记信息 被标记为D的直接删除
- 恢复操作:被标记为C的直接删除 被标记为U的删除当前对象 被标记为D的删除当前对象的标记信息
- */
- }
|