pre version 2

This commit is contained in:
2026-06-17 13:50:41 +02:00
parent c333bbce4e
commit 6909e21b67
26 changed files with 1213 additions and 136 deletions
@@ -0,0 +1,31 @@
<?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
{
Schema::create('google_oauth_connections', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
$table->string('service'); // email, drive, calendar
$table->string('email');
$table->text('access_token');
$table->text('refresh_token')->nullable();
$table->timestamp('expires_at')->nullable();
$table->timestamps();
$table->unique(['user_id', 'service', 'email']);
});
}
public function down(): void
{
Schema::dropIfExists('google_oauth_connections');
}
};
@@ -0,0 +1,54 @@
<?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']);
}
});
}
};