|
@@ -13,17 +13,18 @@ return new class extends Migration
|
|
|
Schema::table('product_variant_images', function (Blueprint $table) {
|
|
Schema::table('product_variant_images', function (Blueprint $table) {
|
|
|
$existing = $this->existingConstraints();
|
|
$existing = $this->existingConstraints();
|
|
|
|
|
|
|
|
- if (in_array('product_variant_images_product_image_id_foreign', $existing['fks'])) {
|
|
|
|
|
- $table->dropForeign('product_variant_images_product_image_id_foreign');
|
|
|
|
|
|
|
+ $tablePrefix = DB::getTablePrefix();
|
|
|
|
|
+ if (in_array( $tablePrefix.'product_variant_images_product_image_id_foreign', $existing['fks'])) {
|
|
|
|
|
+ $table->dropForeign( $tablePrefix.'product_variant_images_product_image_id_foreign');
|
|
|
}
|
|
}
|
|
|
- if (in_array('product_variant_images_product_variant_id_foreign', $existing['fks'])) {
|
|
|
|
|
- $table->dropForeign('product_variant_images_product_variant_id_foreign');
|
|
|
|
|
|
|
+ if (in_array( $tablePrefix.'product_variant_images_product_variant_id_foreign', $existing['fks'])) {
|
|
|
|
|
+ $table->dropForeign( $tablePrefix.'product_variant_images_product_variant_id_foreign');
|
|
|
}
|
|
}
|
|
|
- if (in_array('variant_image_unique', $existing['indexes'])) {
|
|
|
|
|
- $table->dropUnique('variant_image_unique');
|
|
|
|
|
|
|
+ if (in_array( $tablePrefix.'variant_image_unique', $existing['indexes'])) {
|
|
|
|
|
+ $table->dropUnique( $tablePrefix.'variant_image_unique');
|
|
|
}
|
|
}
|
|
|
- if (in_array('idx_image_id', $existing['indexes'])) {
|
|
|
|
|
- $table->dropIndex('idx_image_id');
|
|
|
|
|
|
|
+ if (in_array( $tablePrefix.'idx_image_id', $existing['indexes'])) {
|
|
|
|
|
+ $table->dropIndex( $tablePrefix.'idx_image_id');
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
|
|
@@ -35,7 +36,8 @@ return new class extends Migration
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// ── Step 3: ensure media_id is bigint unsigned to match media.id ─────
|
|
// ── Step 3: ensure media_id is bigint unsigned to match media.id ─────
|
|
|
- DB::statement('ALTER TABLE product_variant_images MODIFY COLUMN media_id BIGINT UNSIGNED NOT NULL');
|
|
|
|
|
|
|
+ $tableName = DB::getTablePrefix() . 'product_variant_images';
|
|
|
|
|
+ DB::statement("ALTER TABLE `{$tableName}` MODIFY COLUMN media_id BIGINT UNSIGNED NOT NULL");
|
|
|
|
|
|
|
|
// ── Step 4: restore constraints ──────────────────────────────────────
|
|
// ── Step 4: restore constraints ──────────────────────────────────────
|
|
|
Schema::table('product_variant_images', function (Blueprint $table) {
|
|
Schema::table('product_variant_images', function (Blueprint $table) {
|
|
@@ -63,7 +65,8 @@ return new class extends Migration
|
|
|
$table->dropIndex('idx_media_id');
|
|
$table->dropIndex('idx_media_id');
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- DB::statement('ALTER TABLE product_variant_images MODIFY COLUMN media_id INT UNSIGNED NOT NULL');
|
|
|
|
|
|
|
+ $tableName = DB::getTablePrefix() . 'product_variant_images';
|
|
|
|
|
+ DB::statement("ALTER TABLE `{$tableName}` MODIFY COLUMN media_id INT UNSIGNED NOT NULL");
|
|
|
|
|
|
|
|
Schema::table('product_variant_images', function (Blueprint $table) {
|
|
Schema::table('product_variant_images', function (Blueprint $table) {
|
|
|
$table->renameColumn('media_id', 'product_image_id');
|
|
$table->renameColumn('media_id', 'product_image_id');
|