|
|
|
@@ -0,0 +1,65 @@ |
|
|
|
<?php |
|
|
|
|
|
|
|
use App\Codes\Model\QRServiceUsage; |
|
|
|
use App\Models\ColumnName; |
|
|
|
use App\Util\MigrationHelper; |
|
|
|
use Illuminate\Database\Migrations\Migration; |
|
|
|
use Illuminate\Database\Schema\Blueprint; |
|
|
|
use Illuminate\Support\Facades\DB; |
|
|
|
use Illuminate\Support\Facades\Schema; |
|
|
|
|
|
|
|
return new class extends Migration |
|
|
|
{ |
|
|
|
|
|
|
|
protected $connection = "htpms_customer"; |
|
|
|
/** |
|
|
|
* Run the migrations. |
|
|
|
*/ |
|
|
|
public function up(): void |
|
|
|
{ |
|
|
|
// バックアップ |
|
|
|
$backup = DB::connection($this->connection)->table("tbl3_mst_shop_no_relations")->get(); |
|
|
|
|
|
|
|
// テーブル削除 |
|
|
|
Schema::drop("tbl3_mst_shop_no_relations"); |
|
|
|
Schema::drop("tbl3_mst_shop_no_relation_histories"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// テーブル作成 |
|
|
|
$schema = function (Blueprint $table, MigrationHelper $helper) { |
|
|
|
$helper->baseColumn() |
|
|
|
->shopId() |
|
|
|
->parkinManagementCode() |
|
|
|
->shopNo(); |
|
|
|
$table->string("qr_service_useage")->comment("QRサービス券利用方法"); |
|
|
|
$helper->index(1, [ColumnName::PARKING_MANAGEMENT_CODE]); |
|
|
|
}; |
|
|
|
MigrationHelper::createTable("tbl3_mst_shop_no_relations", $schema, "HTD 店舗コード紐づけ"); |
|
|
|
MigrationHelper::createTable("tbl3_mst_shop_no_relation_histories", $schema, "HTD 店舗コード紐づけ履歴"); |
|
|
|
|
|
|
|
// ユニーク制約作成 |
|
|
|
MigrationHelper::addUnique("tbl3_mst_shop_no_relations", 1, [ |
|
|
|
ColumnName::SHOP_ID, |
|
|
|
ColumnName::PARKING_MANAGEMENT_CODE, |
|
|
|
"qr_service_useage", |
|
|
|
]); |
|
|
|
|
|
|
|
// データ移行 |
|
|
|
foreach ($backup as $data) { |
|
|
|
DB::connection($this->connection)->table("tbl3_mst_shop_no_relations")->insert( |
|
|
|
[ |
|
|
|
...json_decode(json_encode($data), true), |
|
|
|
"qr_service_useage" => QRServiceUsage::認証方式->value, |
|
|
|
] |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Reverse the migrations. |
|
|
|
*/ |
|
|
|
public function down(): void |
|
|
|
{ |
|
|
|
} |
|
|
|
}; |