Fix dentistry migration MySQL index name length.
Deploy Ladill Care / deploy (push) Successful in 38s
Deploy Ladill Care / deploy (push) Successful in 38s
Shorten composite index names under the 64-character limit and recover partial deploys where treatment plans already exist. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -56,7 +56,7 @@ return new class extends Migration
|
|||||||
$table->timestamp('recorded_at')->nullable();
|
$table->timestamp('recorded_at')->nullable();
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
|
|
||||||
$table->index(['dental_chart_id', 'recorded_at']);
|
$table->index(['dental_chart_id', 'recorded_at'], 'care_den_chart_events_chart_at_idx');
|
||||||
$table->index(['visit_id']);
|
$table->index(['visit_id']);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -78,7 +78,18 @@ return new class extends Migration
|
|||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
$table->softDeletes();
|
$table->softDeletes();
|
||||||
|
|
||||||
$table->index(['organization_id', 'patient_id', 'status']);
|
$table->index(
|
||||||
|
['organization_id', 'patient_id', 'status'],
|
||||||
|
'care_den_plans_org_pt_status_idx',
|
||||||
|
);
|
||||||
|
});
|
||||||
|
} elseif (! $this->hasIndex('care_dental_treatment_plans', 'care_den_plans_org_pt_status_idx')) {
|
||||||
|
// Partial deploy: table created before long auto index name failed (MySQL 64-char limit).
|
||||||
|
Schema::table('care_dental_treatment_plans', function (Blueprint $table) {
|
||||||
|
$table->index(
|
||||||
|
['organization_id', 'patient_id', 'status'],
|
||||||
|
'care_den_plans_org_pt_status_idx',
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,7 +109,7 @@ return new class extends Migration
|
|||||||
$table->text('notes')->nullable();
|
$table->text('notes')->nullable();
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
|
|
||||||
$table->index(['treatment_plan_id', 'status']);
|
$table->index(['treatment_plan_id', 'status'], 'care_den_plan_items_plan_status_idx');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,8 +135,8 @@ return new class extends Migration
|
|||||||
$table->timestamp('performed_at')->nullable();
|
$table->timestamp('performed_at')->nullable();
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
|
|
||||||
$table->index(['visit_id', 'status']);
|
$table->index(['visit_id', 'status'], 'care_den_proc_visit_status_idx');
|
||||||
$table->index(['organization_id', 'procedure_code']);
|
$table->index(['organization_id', 'procedure_code'], 'care_den_proc_org_code_idx');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,8 +156,8 @@ return new class extends Migration
|
|||||||
$table->timestamp('captured_at')->nullable();
|
$table->timestamp('captured_at')->nullable();
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
|
|
||||||
$table->index(['visit_id', 'modality']);
|
$table->index(['visit_id', 'modality'], 'care_den_images_visit_mod_idx');
|
||||||
$table->index(['patient_id', 'captured_at']);
|
$table->index(['patient_id', 'captured_at'], 'care_den_images_patient_cap_idx');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,6 +182,18 @@ return new class extends Migration
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function hasIndex(string $table, string $indexName): bool
|
||||||
|
{
|
||||||
|
$connection = Schema::getConnection();
|
||||||
|
$database = $connection->getDatabaseName();
|
||||||
|
$row = $connection->selectOne(
|
||||||
|
'select 1 as ok from information_schema.statistics where table_schema = ? and table_name = ? and index_name = ? limit 1',
|
||||||
|
[$database, $table, $indexName],
|
||||||
|
);
|
||||||
|
|
||||||
|
return $row !== null;
|
||||||
|
}
|
||||||
|
|
||||||
public function down(): void
|
public function down(): void
|
||||||
{
|
{
|
||||||
Schema::dropIfExists('care_dental_visit_notes');
|
Schema::dropIfExists('care_dental_visit_notes');
|
||||||
|
|||||||
Reference in New Issue
Block a user