Файл: database/upgrades/2026_05_29_000001_merge_admin_adverts_to_adverts.php
Строк: 47
<?php
use IlluminateDatabaseMigrationsMigration;
use IlluminateDatabaseSchemaBlueprint;
use IlluminateSupportFacadesDB;
use IlluminateSupportFacadesSchema;
return new class extends Migration {
public function up(): void
{
if (Schema::hasTable('adverts') && ! Schema::hasColumn('adverts', 'type')) {
Schema::table('adverts', function (Blueprint $table) {
$table->string('type', 10)->default('user')->after('bold');
});
}
Schema::dropIfExists('admin_adverts');
}
public function down(): void
{
if (Schema::hasTable('admin_adverts')) {
return;
}
Schema::create('admin_adverts', function (Blueprint $table) {
$table->increments('id');
$table->string('site', 100);
$table->string('name', 50);
$table->string('color', 10)->nullable();
$table->boolean('bold')->default(false);
$table->integer('user_id');
$table->integer('created_at');
$table->integer('deleted_at')->nullable();
});
if (Schema::hasColumn('adverts', 'type')) {
DB::table('adverts')->where('type', 'admin')->delete();
Schema::table('adverts', function (Blueprint $table) {
$table->dropColumn('type');
});
}
}
};