55 lines
2.0 KiB
PHP
55 lines
2.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use Illuminate\Database\Migrations\Migration;
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
|
return new class extends Migration
|
|
{
|
|
public function up(): void
|
|
{
|
|
if (!Schema::hasColumn('email_settings', 'auth_method')) {
|
|
Schema::table('email_settings', function (Blueprint $table) {
|
|
$table->string('auth_method', 20)->default('password');
|
|
$table->foreignId('google_oauth_connection_id')
|
|
->nullable()
|
|
->constrained('google_oauth_connections')
|
|
->nullOnDelete();
|
|
});
|
|
}
|
|
|
|
if (!Schema::hasColumn('sender_accounts', 'auth_method')) {
|
|
Schema::table('sender_accounts', function (Blueprint $table) {
|
|
$table->string('auth_method', 20)->default('password');
|
|
$table->foreignId('google_oauth_connection_id')
|
|
->nullable()
|
|
->constrained('google_oauth_connections')
|
|
->nullOnDelete();
|
|
});
|
|
}
|
|
}
|
|
|
|
public function down(): void
|
|
{
|
|
Schema::table('email_settings', function (Blueprint $table) {
|
|
if (Schema::hasColumn('email_settings', 'google_oauth_connection_id')) {
|
|
$table->dropForeign(['google_oauth_connection_id']);
|
|
}
|
|
if (Schema::hasColumn('email_settings', 'auth_method')) {
|
|
$table->dropColumn(['auth_method', 'google_oauth_connection_id']);
|
|
}
|
|
});
|
|
|
|
Schema::table('sender_accounts', function (Blueprint $table) {
|
|
if (Schema::hasColumn('sender_accounts', 'google_oauth_connection_id')) {
|
|
$table->dropForeign(['google_oauth_connection_id']);
|
|
}
|
|
if (Schema::hasColumn('sender_accounts', 'auth_method')) {
|
|
$table->dropColumn(['auth_method', 'google_oauth_connection_id']);
|
|
}
|
|
});
|
|
}
|
|
};
|