Files
Website/database/migrations/0001_01_01_000000_create_users_table.php
2024-04-22 18:16:33 +10:00

76 lines
2.6 KiB
PHP

<?php
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
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('users', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->boolean('admin')->default(false);
$table->string('firstname')->nullable();
$table->string('surname')->nullable();
$table->string('phone')->nullable();
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->rememberToken();
$table->string('home_address')->nullable();
$table->string('home_address2')->nullable();
$table->string('home_city')->nullable();
$table->string('home_state')->nullable();
$table->string('home_postcode')->nullable();
$table->string('home_country')->nullable();
$table->string('billing_address')->nullable();
$table->string('billing_address2')->nullable();
$table->string('billing_city')->nullable();
$table->string('billing_state')->nullable();
$table->string('billing_postcode')->nullable();
$table->string('billing_country')->nullable();
$table->timestamps();
});
Schema::create('password_reset_tokens', function (Blueprint $table) {
$table->string('email')->primary();
$table->string('token');
$table->timestamp('created_at')->default(DB::raw('CURRENT_TIMESTAMP'));
});
Schema::create('login_tokens', function (Blueprint $table) {
$table->id();
$table->string('email');
$table->string('token')->unique();
$table->string('intended_url')->nullable();
$table->timestamp('created_at')->default(DB::raw('CURRENT_TIMESTAMP'));
});
Schema::create('sessions', function (Blueprint $table) {
$table->string('id')->primary();
$table->foreignId('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');
}
};