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
|
||||
{
|
||||
if (Schema::hasColumn('student_class', 'semester')) {
|
||||
return;
|
||||
}
|
||||
Schema::table('student_class', function (Blueprint $table) {
|
||||
$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
|
||||
$indexExists = DB::select("SHOW INDEX FROM purchase_order_items WHERE Key_name = 'po_items_inventory_item_idx'");
|
||||
if (empty($indexExists)) {
|
||||
// Add index if it doesn't exist (SQLite-compatible check)
|
||||
$schema = DB::connection()->getDoctrineSchemaManager();
|
||||
$indexes = $schema->listTableIndexes('purchase_order_items');
|
||||
if (! isset($indexes['po_items_inventory_item_idx'])) {
|
||||
Schema::table('purchase_order_items', function (Blueprint $table) {
|
||||
$table->index('inventory_item_id', 'po_items_inventory_item_idx');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user