test borked

This commit is contained in:
Dan Baker 2026-02-22 17:49:23 +00:00
parent 49b528a66b
commit 2418edccfd
29 changed files with 2036 additions and 121 deletions

View file

@ -0,0 +1,43 @@
<?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) {
// Add email_hash column after id if it doesn't exist
if (!Schema::hasColumn('users', 'email_hash')) {
$table->string('email_hash', 64)->unique()->after('id');
}
// Make email, password, and name nullable (temporary during transition)
$table->string('email')->nullable()->change();
$table->string('password')->nullable()->change();
$table->string('name')->nullable()->change();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
// Remove email_hash column
$table->dropUnique(['email_hash']);
$table->dropColumn('email_hash');
// Restore email, password, and name to NOT NULL
$table->string('email')->nullable(false)->change();
$table->string('password')->nullable(false)->change();
$table->string('name')->nullable(false)->change();
});
}
};

View file

@ -0,0 +1,39 @@
<?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('magic_login_tokens', function (Blueprint $table) {
$table->id();
$table->string('email_hash', 64)->index();
$table->string('token_hash');
$table->string('plain_token');
$table->string('code_hash');
$table->string('plain_code', 6);
$table->timestamp('expires_at')->index();
$table->ipAddress('ip_address')->nullable();
$table->text('user_agent')->nullable();
$table->timestamp('used_at')->nullable();
$table->timestamps();
// Composite index for efficient querying of valid tokens
$table->index(['expires_at', 'used_at']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('magic_login_tokens');
}
};

View file

@ -0,0 +1,28 @@
<?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::dropIfExists('password_reset_tokens');
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::create('password_reset_tokens', function (Blueprint $table) {
$table->string('email')->primary();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
}
};

View file

@ -0,0 +1,36 @@
<?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) {
// Drop unique constraint first for SQLite compatibility
$table->dropUnique(['email']);
});
Schema::table('users', function (Blueprint $table) {
// Now drop the password and email columns - we only use email_hash now
$table->dropColumn(['password', 'email']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
// Restore password and email columns
$table->string('email')->unique()->after('email_hash');
$table->string('password')->after('email');
});
}
};