73 lines
2.8 KiB
PHP
73 lines
2.8 KiB
PHP
<?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::create('users', function (Blueprint $table) {
|
|
$table->ulid('id')->primary();
|
|
$table->string('name');
|
|
$table->string('email')->unique();
|
|
$table->timestamp('email_verified_at')->nullable();
|
|
$table->string('password');
|
|
$table->string('role')->default('user');
|
|
$table->text('bio')->nullable();
|
|
$table->unsignedSmallInteger('height')->nullable();
|
|
$table->decimal('target_weight', 5, 2)->nullable();
|
|
$table->date('date_of_birth')->nullable();
|
|
$table->string('sex')->nullable();
|
|
$table->string('physical_activity_level')->nullable();
|
|
$table->string('weight_goal')->nullable();
|
|
$table->string('pace_preference')->nullable();
|
|
$table->string('locale', 8)->default('en')->after('email');
|
|
$table->string('avatar_url', 2048)->nullable();
|
|
$table->timestampTz('onboarding_completed_at')->nullable()->index();
|
|
$table->timestampTz('nutrition_estimate_accepted_at')->nullable();
|
|
// Moderation
|
|
$table->timestamp('suspended_at')->nullable()->after('deleted_at')->index();
|
|
$table->ulid('suspended_by')->nullable()->after('suspended_at')->index();
|
|
$table->text('suspended_reason')->nullable()->after('suspended_by');
|
|
$table->rememberToken();
|
|
$table->timestampTz('account_verified_at')->nullable();
|
|
$table->timestamps();
|
|
$table->softDeletesTz();
|
|
});
|
|
|
|
Schema::table('users', function (Blueprint $table) {
|
|
$table->foreign('suspended_by')->references('id')->on('users')->nullOnDelete();
|
|
});
|
|
|
|
Schema::create('password_reset_tokens', function (Blueprint $table) {
|
|
$table->string('email')->primary();
|
|
$table->string('token');
|
|
$table->timestamp('created_at')->nullable();
|
|
});
|
|
|
|
Schema::create('sessions', function (Blueprint $table) {
|
|
$table->string('id')->primary();
|
|
$table->foreignUlid('user_id')->nullable()->index();
|
|
$table->string('ip_address', 45)->nullable();
|
|
$table->text('user_agent')->nullable();
|
|
$table->longText('payload');
|
|
$table->integer('last_activity')->index();
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Reverse the migrations.
|
|
*/
|
|
public function down(): void
|
|
{
|
|
Schema::dropIfExists('users');
|
|
Schema::dropIfExists('password_reset_tokens');
|
|
Schema::dropIfExists('sessions');
|
|
}
|
|
};
|