Fix migrations for SQLite: add hasColumn check, replace SHOW INDEX with Doctrine schema manager
This commit is contained in:
@@ -11,6 +11,9 @@ return new class extends Migration
|
|||||||
*/
|
*/
|
||||||
public function up(): void
|
public function up(): void
|
||||||
{
|
{
|
||||||
|
if (Schema::hasColumn('student_class', 'semester')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
Schema::table('student_class', function (Blueprint $table) {
|
Schema::table('student_class', function (Blueprint $table) {
|
||||||
$table->string('semester', 255)->default('')->after('is_event_only');
|
$table->string('semester', 255)->default('')->after('is_event_only');
|
||||||
});
|
});
|
||||||
|
|||||||
+4
-3
@@ -18,9 +18,10 @@ return new class extends Migration
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Add index if it doesn't exist
|
// Add index if it doesn't exist (SQLite-compatible check)
|
||||||
$indexExists = DB::select("SHOW INDEX FROM purchase_order_items WHERE Key_name = 'po_items_inventory_item_idx'");
|
$schema = DB::connection()->getDoctrineSchemaManager();
|
||||||
if (empty($indexExists)) {
|
$indexes = $schema->listTableIndexes('purchase_order_items');
|
||||||
|
if (! isset($indexes['po_items_inventory_item_idx'])) {
|
||||||
Schema::table('purchase_order_items', function (Blueprint $table) {
|
Schema::table('purchase_order_items', function (Blueprint $table) {
|
||||||
$table->index('inventory_item_id', 'po_items_inventory_item_idx');
|
$table->index('inventory_item_id', 'po_items_inventory_item_idx');
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user