major update

This commit is contained in:
Mark Gregory
2026-06-10 14:04:49 +01:00
parent b10ac13bb5
commit 276f03a17b
26 changed files with 129 additions and 152 deletions
@@ -15,19 +15,23 @@ return new class extends Migration
return;
}
Schema::table('users', function (Blueprint $table): void {
if (! Schema::hasColumn('users', 'two_factor_secret')) {
if (! Schema::hasColumn('users', 'two_factor_secret')) {
Schema::table('users', function (Blueprint $table): void {
$table->text('two_factor_secret')->nullable()->after('password');
}
});
}
if (! Schema::hasColumn('users', 'two_factor_recovery_codes')) {
if (! Schema::hasColumn('users', 'two_factor_recovery_codes')) {
Schema::table('users', function (Blueprint $table): void {
$table->text('two_factor_recovery_codes')->nullable()->after('two_factor_secret');
}
});
}
if (! Schema::hasColumn('users', 'two_factor_confirmed_at')) {
if (! Schema::hasColumn('users', 'two_factor_confirmed_at')) {
Schema::table('users', function (Blueprint $table): void {
$table->timestamp('two_factor_confirmed_at')->nullable()->after('two_factor_recovery_codes');
}
});
});
}
}
/**
@@ -39,12 +43,12 @@ return new class extends Migration
return;
}
Schema::table('users', function (Blueprint $table): void {
foreach (['two_factor_confirmed_at', 'two_factor_recovery_codes', 'two_factor_secret'] as $column) {
if (Schema::hasColumn('users', $column)) {
foreach (['two_factor_confirmed_at', 'two_factor_recovery_codes', 'two_factor_secret'] as $column) {
if (Schema::hasColumn('users', $column)) {
Schema::table('users', function (Blueprint $table) use ($column): void {
$table->dropColumn($column);
}
});
}
});
}
}
};
@@ -1,50 +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.
* This migration is intentionally a no-op.
*
* The two-factor columns are managed by:
* 2025_08_14_170933_add_two_factor_columns_to_users_table.php
*
* Keeping this file prevents migration-history churn while avoiding duplicate
* column failures in SQLite, MySQL and PostgreSQL.
*/
public function up(): void
{
if (! Schema::hasTable('users')) {
return;
}
Schema::table('users', function (Blueprint $table): void {
if (! Schema::hasColumn('users', 'two_factor_secret')) {
$table->text('two_factor_secret')->nullable()->after('password');
}
if (! Schema::hasColumn('users', 'two_factor_recovery_codes')) {
$table->text('two_factor_recovery_codes')->nullable()->after('two_factor_secret');
}
if (! Schema::hasColumn('users', 'two_factor_confirmed_at')) {
$table->timestamp('two_factor_confirmed_at')->nullable()->after('two_factor_recovery_codes');
}
});
//
}
/**
* Reverse the migrations.
* Reverse the migration.
*/
public function down(): void
{
if (! Schema::hasTable('users')) {
return;
}
Schema::table('users', function (Blueprint $table): void {
foreach (['two_factor_confirmed_at', 'two_factor_recovery_codes', 'two_factor_secret'] as $column) {
if (Schema::hasColumn('users', $column)) {
$table->dropColumn($column);
}
}
});
//
}
};