test borked
This commit is contained in:
parent
49b528a66b
commit
2418edccfd
29 changed files with 2036 additions and 121 deletions
|
|
@ -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();
|
||||
});
|
||||
}
|
||||
};
|
||||
39
database/migrations/2026_02_22_000002_create_magic_login_tokens_table.php
Executable file
39
database/migrations/2026_02_22_000002_create_magic_login_tokens_table.php
Executable 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');
|
||||
}
|
||||
};
|
||||
28
database/migrations/2026_02_22_000003_drop_password_reset_tokens_table.php
Executable file
28
database/migrations/2026_02_22_000003_drop_password_reset_tokens_table.php
Executable 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();
|
||||
});
|
||||
}
|
||||
};
|
||||
36
database/migrations/2026_02_22_000004_remove_password_from_users_table.php
Executable file
36
database/migrations/2026_02_22_000004_remove_password_from_users_table.php
Executable 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');
|
||||
});
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue