2021_03_09_172210_change_price_model_table.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. use Illuminate\Database\Migrations\Migration;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Support\Facades\Schema;
  5. class ChangePriceModelTable extends Migration
  6. {
  7. protected $tables = ["owner_storage_price_models","owner_price_operations","owner_price_logistics","owner_price_expresses","owner_price_direct_logistics"];
  8. /**
  9. * Run the migrations.
  10. *
  11. * @return void
  12. */
  13. public function up()
  14. {
  15. foreach ($this->tables as $table){
  16. Schema::table($table,function (Blueprint $table){
  17. $table->char("operation",1)->index()->nullable()->comment("操作类型");
  18. $table->bigInteger("target_id")->index()->nullable()->comment("目标ID");
  19. });
  20. }
  21. }
  22. /**
  23. * Reverse the migrations.
  24. *
  25. * @return void
  26. */
  27. public function down()
  28. {
  29. foreach ($this->tables as $table){
  30. Schema::table($table,function (Blueprint $table){
  31. $table->dropColumn("operation",1);
  32. $table->dropColumn("target_id");
  33. });
  34. }
  35. }
  36. /*TODO 可回滚数据功能:1.增加两个字段 operation(哪种类型操作) target_id(映射目标)
  37. 2.新增操作:未审核时增加operation为C
  38. 修改前提,对应的映射目标不可被查看修改
  39. 3.修改操作:当前修改对象是否为被标记过对象,是->直接修改当前对象 否->生成标记对象
  40. 3.删除操作:当前删除对象是否为被标记过对象,是->目标是否存在(是->删除当前对象,将目标对象标记为删除 否->将当前对象标记为删除) 否->将当前对象标记为删除
  41. 审核操作:被标记为C的删除标记信息 被标记为U的删除目标对象与当前对象的标记信息 被标记为D的直接删除
  42. 恢复操作:被标记为C的直接删除 被标记为U的删除当前对象 被标记为D的删除当前对象的标记信息
  43. */
  44. }