Generische iCal-Kanäle mit Bestandsklärung und sicheren Exporten bereitstellen
Deploy FeWo mit PipelineManager / deploy (push) Successful in 2m33s

This commit is contained in:
Lars committed 2026-10-27 17:14:45 +01:00
1 parent 6fe5bbc6e3
commit 783068501c
42 files changed
+2646 -248

No files matched your search

@@ -0,0 +1,76 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('channels', function (Blueprint $table) {
$table->string('status')->default('setup');
$table->string('booking_model')->default('mixed');
$table->boolean('import_enabled')->default(false);
$table->boolean('export_enabled')->default(false);
$table->string('export_mode')->default('test');
$table->unsignedInteger('external_poll_minutes')->nullable();
$table->dateTime('last_error_at')->nullable();
$table->unsignedInteger('last_import_events')->default(0);
$table->json('sync_warnings')->nullable();
$table->longText('export_snapshot')->nullable();
$table->dateTime('export_snapshot_at')->nullable();
$table->dateTime('last_export_requested_at')->nullable();
$table->string('previous_export_token', 64)->nullable()->unique();
$table->dateTime('previous_export_token_expires_at')->nullable();
});
Schema::table('blocked_periods', function (Blueprint $table) {
$table->foreignId('origin_channel_id')->nullable()->constrained('channels')->restrictOnDelete();
$table->boolean('needs_review')->default(false);
$table->text('review_note')->nullable();
$table->unsignedInteger('missing_imports')->default(0);
});
Schema::table('bookings', function (Blueprint $table) {
$table->foreignId('import_channel_id')->nullable()->constrained('channels')->restrictOnDelete();
$table->foreignId('origin_channel_id')->nullable()->constrained('channels')->restrictOnDelete();
});
Schema::table('channel_sync_logs', fn (Blueprint $table) => $table->json('warnings')->nullable());
/** Preserve existing directions and export scope without changing any occupancy. */
DB::table('channels')->orderBy('id')->each(function (object $channel): void {
$settings = json_decode($channel->settings ?? '{}', true) ?: [];
DB::table('channels')->where('id', $channel->id)->update([
'status' => $channel->is_active ? 'active' : 'paused',
'import_enabled' => $channel->is_active && filled($settings['import_url'] ?? null),
'export_enabled' => (bool) $channel->is_active,
'export_mode' => 'regular',
]);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('bookings', function (Blueprint $table) {
$table->dropConstrainedForeignId('origin_channel_id');
$table->dropConstrainedForeignId('import_channel_id');
});
Schema::table('blocked_periods', function (Blueprint $table) {
$table->dropConstrainedForeignId('origin_channel_id');
$table->dropColumn(['needs_review', 'review_note', 'missing_imports']);
});
Schema::table('channel_sync_logs', fn (Blueprint $table) => $table->dropColumn('warnings'));
Schema::table('channels', fn (Blueprint $table) => $table->dropUnique(['previous_export_token']));
Schema::table('channels', fn (Blueprint $table) => $table->dropColumn([
'status', 'booking_model', 'import_enabled', 'export_enabled', 'export_mode', 'external_poll_minutes',
'last_error_at', 'last_import_events', 'sync_warnings', 'export_snapshot', 'export_snapshot_at',
'last_export_requested_at', 'previous_export_token', 'previous_export_token_expires_at',
]));
}
};
@@ -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('channels', function (Blueprint $table): void {
$table->string('echo_behavior')->default('unverified');
$table->text('echo_notes')->nullable();
$table->text('operating_notes')->nullable();
$table->dateTime('portal_verified_at')->nullable();
});
Schema::table('blocked_periods', function (Blueprint $table): void {
$table->softDeletes();
$table->boolean('is_representation')->default(false);
$table->foreignId('canonical_block_id')->nullable()->constrained('blocked_periods')->nullOnDelete();
$table->foreignId('linked_booking_id')->nullable()->constrained('bookings')->nullOnDelete();
$table->boolean('export_approved')->default(true);
$table->dateTime('reviewed_at')->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('blocked_periods', function (Blueprint $table): void {
$table->dropConstrainedForeignId('canonical_block_id');
$table->dropConstrainedForeignId('linked_booking_id');
$table->dropColumn(['is_representation', 'export_approved', 'reviewed_at']);
$table->dropSoftDeletes();
});
Schema::table('channels', fn (Blueprint $table) => $table->dropColumn(['echo_behavior', 'echo_notes', 'operating_notes', 'portal_verified_at']));
}
};