feat(server): add show_on_tv product flag and public /tv products API
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
<?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('products')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Schema::hasColumn('products', 'show_on_tv')) {
|
||||
Schema::table('products', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('products', 'show_in_assets')) {
|
||||
$table->boolean('show_on_tv')->default(false)->after('show_in_assets');
|
||||
} elseif (Schema::hasColumn('products', 'show')) {
|
||||
$table->boolean('show_on_tv')->default(false)->after('show');
|
||||
} else {
|
||||
$table->boolean('show_on_tv')->default(false);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
DB::statement(
|
||||
'ALTER TABLE `products` MODIFY COLUMN `show_on_tv` TINYINT(1) NOT NULL DEFAULT 0'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
if (!Schema::hasTable('products') || !Schema::hasColumn('products', 'show_on_tv')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Schema::table('products', function (Blueprint $table) {
|
||||
$table->dropColumn('show_on_tv');
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user