schema(false)); MigrationHelper::createTable('user_histories', $this->schema(true)); } /** * Reverse the migrations. */ public function down(): void { Schema::dropIfExists('users'); Schema::dropIfExists('user_histories'); } private function schema(bool $forHistory) { return function (Blueprint $table, MigrationHelper $helper) use ($forHistory) { $helper->baseColumn() ->contractId(); $table->string('email')->comment("Email")->nullable(); $table->string('password')->comment("ログインパスワード")->nullable(); $table->unsignedTinyInteger("role")->comment("認可")->nullable(); $table->string('name')->comment("氏名")->nullable(); $helper->index(1, [ColumnName::CONTRACT_ID]); if ($forHistory) { $helper->index(2, ['email']); } else { $helper->unique(1, ['email']); } }; } };