feat: regroup migrations

This commit is contained in:
Leon 2026-01-07 15:20:53 +01:00
parent 499b645fa4
commit 44c48316dc
11 changed files with 12 additions and 271 deletions

View File

@ -1,5 +1,6 @@
<?php
use App\Enums\UserRole;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
@ -15,9 +16,16 @@ return new class extends Migration
$table->uuid('id')->primary();
$table->string('username');
$table->string('email')->unique();
$table->integer('xp')->default(0);
$table->integer('participations')->default(0);
$table->integer('victories')->default(0);
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->string('role')->default(UserRole::USER->value);
$table->string('avatar_uri')->nullable();
$table->unsignedInteger('level')->default(1);
$table->rememberToken();
$table->softDeletes();
$table->timestamps();
});

View File

@ -1,28 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropSoftDeletes();
});
}
};

View File

@ -1,5 +1,6 @@
<?php
use App\Enums\HuntDifficulty;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
@ -12,14 +13,15 @@ return new class extends Migration
public function up(): void
{
Schema::create('hunts', function (Blueprint $table) {
$table->string('partner_id')->index();
$table->id();
$table->string('partner_id')->nullable()->index();
$table->string('title');
$table->string('slug')->unique();
$table->text('description')->nullable();
$table->string('status')->index();
$table->string('difficulty')->index();
$table->string('difficulty')->default(HuntDifficulty::EASY->value)->index();
$table->string('city')->index();
$table->decimal('latitude', 10, 7)->nullable();

View File

@ -1,30 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->integer('xp')->default(0);
$table->integer('participations')->default(0);
$table->integer('victories')->default(0);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
//
});
}
};

View File

@ -1,33 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('hunts', function (Blueprint $table) {
if (!Schema::hasColumn('hunts', 'id')) {
$table->id();
}
if (!Schema::hasColumn('hunts', 'xp')) {
$table->unsignedBigInteger('xp')->default(0);
}
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('hunts', function (Blueprint $table) {
//
});
}
};

View File

@ -1,28 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->string('role')->default('user');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
//
});
}
};

View File

@ -1,28 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('hunts', function (Blueprint $table) {
$table->string('partner_id')->nullable()->change();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('hunts', function (Blueprint $table) {
$table->string('partner_id')->nullable(false)->change();
});
}
};

View File

@ -1,28 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->string('avatarUri')->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('avatarUri');
});
}
};

View File

@ -1,28 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->renameColumn('avatarUri', 'avatar_uri');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->renameColumn('avatar_uri', 'avatarUri');
});
}
};

View File

@ -1,38 +0,0 @@
<?php
use App\Enums\HuntDifficulty;
use App\Enums\UserRole;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('hunts', function (Blueprint $table) {
$table->string('difficulty')->default(HuntDifficulty::EASY->value)->change();
});
Schema::table('users', function (Blueprint $table) {
$table->string('role')->default(UserRole::USER->value)->change();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('hunts', function (Blueprint $table) {
$table->string('difficulty')->nullable(false)->change();
});
Schema::table('users', function (Blueprint $table) {
$table->string('role')->default('user')->change(); // Originally it was default 'user' string, restoring to that or removing default if it had none before (but it did have one).
});
}
};

View File

@ -1,28 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->unsignedInteger('level')->default(1);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('level');
});
}
};