領収証発行サービス
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 line
1.4KB

  1. <?php
  2. use App\Models\ColumnName;
  3. use App\Util\MigrationHelper;
  4. use Illuminate\Database\Migrations\Migration;
  5. use Illuminate\Database\Schema\Blueprint;
  6. use Illuminate\Support\Facades\Schema;
  7. return new class extends Migration
  8. {
  9. /**
  10. * Run the migrations.
  11. */
  12. public function up(): void
  13. {
  14. MigrationHelper::createTable('users', $this->schema(false));
  15. MigrationHelper::createTable('user_histories', $this->schema(true));
  16. }
  17. /**
  18. * Reverse the migrations.
  19. */
  20. public function down(): void
  21. {
  22. Schema::dropIfExists('users');
  23. Schema::dropIfExists('user_histories');
  24. }
  25. private function schema(bool $forHistory)
  26. {
  27. return function (Blueprint $table, MigrationHelper $helper) use ($forHistory) {
  28. $helper->baseColumn()
  29. ->contractId();
  30. $table->string('email')->comment("Email")->nullable();
  31. $table->string('password')->comment("ログインパスワード")->nullable();
  32. $table->unsignedTinyInteger("role")->comment("認可")->nullable();
  33. $table->string('name')->comment("氏名")->nullable();
  34. $helper->index(1, [ColumnName::CONTRACT_ID]);
  35. if ($forHistory) {
  36. $helper->index(2, ['email']);
  37. } else {
  38. $helper->unique(1, ['email']);
  39. }
  40. };
  41. }
  42. };