feat: complete administration and reporting
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
<?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
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('portal_settings', function (Blueprint $table) {
|
||||
$table->string('key')->primary();
|
||||
$table->json('value');
|
||||
$table->text('description')->nullable();
|
||||
$table->foreignId('updated_by')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->timestampsTz();
|
||||
});
|
||||
|
||||
Schema::table('reservation_items', function (Blueprint $table) {
|
||||
$table->timestampTz('buffer_starts_at')->nullable()->index()->after('ends_at');
|
||||
$table->timestampTz('buffer_ends_at')->nullable()->index()->after('buffer_starts_at');
|
||||
});
|
||||
DB::table('reservation_items')->update([
|
||||
'buffer_starts_at' => DB::raw('starts_at'),
|
||||
'buffer_ends_at' => DB::raw('ends_at'),
|
||||
]);
|
||||
|
||||
if (DB::getDriverName() === 'pgsql') {
|
||||
DB::statement('ALTER TABLE reservation_items DROP CONSTRAINT reservation_items_no_blocking_overlap');
|
||||
DB::statement('ALTER TABLE reservation_items ALTER COLUMN buffer_starts_at SET NOT NULL');
|
||||
DB::statement('ALTER TABLE reservation_items ALTER COLUMN buffer_ends_at SET NOT NULL');
|
||||
DB::statement(<<<'SQL'
|
||||
ALTER TABLE reservation_items
|
||||
ADD CONSTRAINT reservation_items_no_blocking_overlap
|
||||
EXCLUDE USING gist (
|
||||
snipe_asset_id WITH =,
|
||||
tstzrange(buffer_starts_at, buffer_ends_at, '[)') WITH &&
|
||||
)
|
||||
WHERE (status IN ('held', 'reserved', 'ready', 'delivered'))
|
||||
SQL);
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
if (DB::getDriverName() === 'pgsql') {
|
||||
DB::statement('ALTER TABLE reservation_items DROP CONSTRAINT reservation_items_no_blocking_overlap');
|
||||
DB::statement(<<<'SQL'
|
||||
ALTER TABLE reservation_items
|
||||
ADD CONSTRAINT reservation_items_no_blocking_overlap
|
||||
EXCLUDE USING gist (
|
||||
snipe_asset_id WITH =,
|
||||
tstzrange(starts_at, ends_at, '[)') WITH &&
|
||||
)
|
||||
WHERE (status IN ('held', 'reserved', 'ready', 'delivered'))
|
||||
SQL);
|
||||
}
|
||||
|
||||
Schema::table('reservation_items', function (Blueprint $table) {
|
||||
$table->dropColumn(['buffer_starts_at', 'buffer_ends_at']);
|
||||
});
|
||||
Schema::dropIfExists('portal_settings');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user