Make recent Care migrations idempotent for partial deploys.
Deploy Ladill Care / deploy (push) Successful in 1m16s

Skip create when the table already exists so migrate can record and continue.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
isaacclad
2026-07-18 11:26:28 +00:00
co-authored by Cursor
parent dee9a0f2df
commit 34ca1365b9
3 changed files with 104 additions and 90 deletions
@@ -8,69 +8,75 @@ return new class extends Migration
{
public function up(): void
{
Schema::create('care_service_queues', function (Blueprint $table) {
$table->id();
$table->uuid('uuid')->unique();
$table->string('owner_ref', 64)->index();
$table->foreignId('organization_id')->constrained('care_organizations')->cascadeOnDelete();
$table->foreignId('branch_id')->constrained('care_branches')->cascadeOnDelete();
$table->string('context', 64);
$table->string('name');
$table->string('prefix', 8);
$table->string('routing_mode', 32)->default('shared_pool');
$table->string('external_key')->nullable()->index();
$table->unsignedInteger('next_number')->default(1);
$table->boolean('is_active')->default(true);
$table->timestamps();
if (! Schema::hasTable('care_service_queues')) {
Schema::create('care_service_queues', function (Blueprint $table) {
$table->id();
$table->uuid('uuid')->unique();
$table->string('owner_ref', 64)->index();
$table->foreignId('organization_id')->constrained('care_organizations')->cascadeOnDelete();
$table->foreignId('branch_id')->constrained('care_branches')->cascadeOnDelete();
$table->string('context', 64);
$table->string('name');
$table->string('prefix', 8);
$table->string('routing_mode', 32)->default('shared_pool');
$table->string('external_key')->nullable()->index();
$table->unsignedInteger('next_number')->default(1);
$table->boolean('is_active')->default(true);
$table->timestamps();
$table->unique(['organization_id', 'branch_id', 'context']);
});
$table->unique(['organization_id', 'branch_id', 'context']);
});
}
Schema::create('care_service_points', function (Blueprint $table) {
$table->id();
$table->uuid('uuid')->unique();
$table->string('owner_ref', 64)->index();
$table->foreignId('organization_id')->constrained('care_organizations')->cascadeOnDelete();
$table->foreignId('service_queue_id')->constrained('care_service_queues')->cascadeOnDelete();
$table->string('name');
$table->string('destination')->nullable();
$table->string('kind', 32)->default('default');
$table->unsignedBigInteger('ref_id')->nullable();
$table->string('staff_ref')->nullable();
$table->string('staff_display_name')->nullable();
$table->string('external_key')->nullable()->index();
$table->boolean('is_active')->default(true);
$table->timestamps();
if (! Schema::hasTable('care_service_points')) {
Schema::create('care_service_points', function (Blueprint $table) {
$table->id();
$table->uuid('uuid')->unique();
$table->string('owner_ref', 64)->index();
$table->foreignId('organization_id')->constrained('care_organizations')->cascadeOnDelete();
$table->foreignId('service_queue_id')->constrained('care_service_queues')->cascadeOnDelete();
$table->string('name');
$table->string('destination')->nullable();
$table->string('kind', 32)->default('default');
$table->unsignedBigInteger('ref_id')->nullable();
$table->string('staff_ref')->nullable();
$table->string('staff_display_name')->nullable();
$table->string('external_key')->nullable()->index();
$table->boolean('is_active')->default(true);
$table->timestamps();
$table->unique(['service_queue_id', 'external_key']);
});
$table->unique(['service_queue_id', 'external_key']);
});
}
Schema::create('care_queue_tickets', function (Blueprint $table) {
$table->id();
$table->uuid('uuid')->unique();
$table->string('owner_ref', 64)->index();
$table->foreignId('organization_id')->constrained('care_organizations')->cascadeOnDelete();
$table->foreignId('service_queue_id')->constrained('care_service_queues')->cascadeOnDelete();
$table->foreignId('service_point_id')->nullable()->constrained('care_service_points')->nullOnDelete();
$table->string('ticket_number', 32);
$table->string('status', 32)->default('waiting')->index();
$table->string('priority', 32)->default('walk_in');
$table->string('source', 32)->default('api');
$table->string('customer_name')->nullable();
$table->string('customer_phone')->nullable();
$table->string('care_entity', 32)->nullable();
$table->string('care_entity_uuid', 36)->nullable()->index();
$table->unsignedBigInteger('care_entity_id')->nullable();
$table->unsignedBigInteger('visit_id')->nullable();
$table->json('metadata')->nullable();
$table->timestamp('called_at')->nullable();
$table->timestamp('serving_at')->nullable();
$table->timestamp('completed_at')->nullable();
$table->timestamps();
if (! Schema::hasTable('care_queue_tickets')) {
Schema::create('care_queue_tickets', function (Blueprint $table) {
$table->id();
$table->uuid('uuid')->unique();
$table->string('owner_ref', 64)->index();
$table->foreignId('organization_id')->constrained('care_organizations')->cascadeOnDelete();
$table->foreignId('service_queue_id')->constrained('care_service_queues')->cascadeOnDelete();
$table->foreignId('service_point_id')->nullable()->constrained('care_service_points')->nullOnDelete();
$table->string('ticket_number', 32);
$table->string('status', 32)->default('waiting')->index();
$table->string('priority', 32)->default('walk_in');
$table->string('source', 32)->default('api');
$table->string('customer_name')->nullable();
$table->string('customer_phone')->nullable();
$table->string('care_entity', 32)->nullable();
$table->string('care_entity_uuid', 36)->nullable()->index();
$table->unsignedBigInteger('care_entity_id')->nullable();
$table->unsignedBigInteger('visit_id')->nullable();
$table->json('metadata')->nullable();
$table->timestamp('called_at')->nullable();
$table->timestamp('serving_at')->nullable();
$table->timestamp('completed_at')->nullable();
$table->timestamps();
$table->index(['service_queue_id', 'status']);
$table->index(['service_point_id', 'status']);
});
$table->index(['service_queue_id', 'status']);
$table->index(['service_point_id', 'status']);
});
}
}
public function down(): void
@@ -8,6 +8,10 @@ return new class extends Migration
{
public function up(): void
{
if (Schema::hasTable('care_specialty_clinical_records')) {
return;
}
Schema::create('care_specialty_clinical_records', function (Blueprint $table) {
$table->id();
$table->uuid('uuid')->unique();
@@ -8,40 +8,44 @@ return new class extends Migration
{
public function up(): void
{
Schema::create('care_display_screens', function (Blueprint $table) {
$table->id();
$table->uuid('uuid')->unique();
$table->string('owner_ref')->index();
$table->foreignId('organization_id')->constrained('care_organizations')->cascadeOnDelete();
$table->foreignId('branch_id')->constrained('care_branches')->cascadeOnDelete();
$table->string('name');
$table->string('layout')->default('standard');
$table->string('access_token')->unique();
$table->json('service_queue_ids')->nullable();
$table->json('settings')->nullable();
$table->boolean('is_active')->default(true);
$table->timestamp('last_seen_at')->nullable();
$table->timestamps();
$table->softDeletes();
});
if (! Schema::hasTable('care_display_screens')) {
Schema::create('care_display_screens', function (Blueprint $table) {
$table->id();
$table->uuid('uuid')->unique();
$table->string('owner_ref')->index();
$table->foreignId('organization_id')->constrained('care_organizations')->cascadeOnDelete();
$table->foreignId('branch_id')->constrained('care_branches')->cascadeOnDelete();
$table->string('name');
$table->string('layout')->default('standard');
$table->string('access_token')->unique();
$table->json('service_queue_ids')->nullable();
$table->json('settings')->nullable();
$table->boolean('is_active')->default(true);
$table->timestamp('last_seen_at')->nullable();
$table->timestamps();
$table->softDeletes();
});
}
Schema::create('care_voice_announcements', function (Blueprint $table) {
$table->id();
$table->string('owner_ref')->index();
$table->foreignId('organization_id')->constrained('care_organizations')->cascadeOnDelete();
$table->foreignId('branch_id')->constrained('care_branches')->cascadeOnDelete();
$table->foreignId('ticket_id')->nullable()->constrained('care_queue_tickets')->nullOnDelete();
$table->string('locale', 10)->default('en');
$table->text('message');
$table->string('voice')->default('female');
$table->unsignedTinyInteger('volume')->default(80);
$table->unsignedTinyInteger('repeat_count')->default(1);
$table->string('status')->default('pending');
$table->timestamp('played_at')->nullable();
$table->timestamps();
if (! Schema::hasTable('care_voice_announcements')) {
Schema::create('care_voice_announcements', function (Blueprint $table) {
$table->id();
$table->string('owner_ref')->index();
$table->foreignId('organization_id')->constrained('care_organizations')->cascadeOnDelete();
$table->foreignId('branch_id')->constrained('care_branches')->cascadeOnDelete();
$table->foreignId('ticket_id')->nullable()->constrained('care_queue_tickets')->nullOnDelete();
$table->string('locale', 10)->default('en');
$table->text('message');
$table->string('voice')->default('female');
$table->unsignedTinyInteger('volume')->default(80);
$table->unsignedTinyInteger('repeat_count')->default(1);
$table->string('status')->default('pending');
$table->timestamp('played_at')->nullable();
$table->timestamps();
$table->index(['branch_id', 'status']);
});
$table->index(['branch_id', 'status']);
});
}
}
public function down(): void