Implement catalog CRUD overhaul, snapshot fallback activation, and billing/UX hardening
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
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::table('user_keywords', function (Blueprint $table): void {
|
||||
$table->boolean('is_active')->default(true)->after('lang');
|
||||
$table->index(['user_id', 'is_active']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('user_keywords', function (Blueprint $table): void {
|
||||
$table->dropIndex(['user_id', 'is_active']);
|
||||
$table->dropColumn('is_active');
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
<?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
|
||||
{
|
||||
if (!Schema::hasTable('emojis')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$duplicates = DB::table('emojis')
|
||||
->select('slug', DB::raw('COUNT(*) as aggregate'))
|
||||
->groupBy('slug')
|
||||
->havingRaw('COUNT(*) > 1')
|
||||
->limit(5)
|
||||
->pluck('slug')
|
||||
->all();
|
||||
|
||||
if (!empty($duplicates)) {
|
||||
throw new \RuntimeException(
|
||||
'Cannot add unique index on emojis.slug because duplicate slugs exist: '.implode(', ', $duplicates)
|
||||
);
|
||||
}
|
||||
|
||||
Schema::table('emojis', function (Blueprint $table): void {
|
||||
$table->unique('slug', 'emojis_slug_unique');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
if (!Schema::hasTable('emojis')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Schema::table('emojis', function (Blueprint $table): void {
|
||||
$table->dropUnique('emojis_slug_unique');
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user