fix: migration 2FA lỗi Invalid default value cho expires_at

MySQL tắt explicit_defaults_for_timestamp gán default 0000-00-00 cho
TIMESTAMP NOT NULL không phải cột timestamp đầu tiên, bị NO_ZERO_DATE chặn.
Đổi expires_at sang DATETIME; bỏ qua thêm two_factor_enabled nếu đã có
(DDL MySQL không rollback nên lần chạy lỗi trước đã thêm cột).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
baodev0
2026-10-15 08:31:18 +07:00
co-authored by Claude Opus 5.5
parent 0bd15f6018
commit 725edb11a3
@@ -7,9 +7,11 @@ use Illuminate\Support\Facades\Schema;
return new class extends Migration {
public function up(): void
{
Schema::table('customers', function (Blueprint $table) {
$table->boolean('two_factor_enabled')->default(false);
});
if (! Schema::hasColumn('customers', 'two_factor_enabled')) {
Schema::table('customers', function (Blueprint $table) {
$table->boolean('two_factor_enabled')->default(false);
});
}
Schema::create('customer_trusted_devices', function (Blueprint $table) {
$table->id();
@@ -18,7 +20,7 @@ return new class extends Migration {
$table->string('user_agent', 255)->nullable();
$table->string('ip_address', 45)->nullable();
$table->timestamp('last_used_at')->nullable();
$table->timestamp('expires_at')->index();
$table->dateTime('expires_at')->index();
$table->timestamps();
});
}