invoiceninja/elastic/migrations
David Bomba 142bc03658 fix: Add idempotency checks to all Elasticsearch migrations
Problem:
- Running elastic:rebuild --model=X failed when indexes already existed
- Migrations threw "index already exists" errors in production
- Command runs ALL migrations even when rebuilding single model

Solution:
- Added existence checks to all 12 migration files
- Migrations now skip creation if index already exists
- Safe to run multiple times without errors

Changes:
- Added ClientBuilder import to all migrations
- Check indices()->exists() before creating
- Return early if index already exists
- Removed force drop from recurring_invoices migration

Benefits:
- Production-safe partial rebuilds
- No "already exists" errors
- Idempotent migrations
- Clean log output

Files modified:
- All 12 files in elastic/migrations/*.php
2025-11-26 02:15:02 +00:00
..
2025_08_31_221640_create_invoices_index.php fix: Add idempotency checks to all Elasticsearch migrations 2025-11-26 02:15:02 +00:00
2025_08_31_221641_create_quotes_index.php fix: Add idempotency checks to all Elasticsearch migrations 2025-11-26 02:15:02 +00:00
2025_08_31_221642_create_credits_index.php fix: Add idempotency checks to all Elasticsearch migrations 2025-11-26 02:15:02 +00:00
2025_08_31_221643_create_recurring_invoices_index.php fix: Add idempotency checks to all Elasticsearch migrations 2025-11-26 02:15:02 +00:00
2025_08_31_221644_create_purchase_orders_index.php fix: Add idempotency checks to all Elasticsearch migrations 2025-11-26 02:15:02 +00:00
2025_08_31_221645_create_vendors_index.php fix: Add idempotency checks to all Elasticsearch migrations 2025-11-26 02:15:02 +00:00
2025_08_31_221646_create_expenses_index.php fix: Add idempotency checks to all Elasticsearch migrations 2025-11-26 02:15:02 +00:00
2025_08_31_221647_create_projects_index.php fix: Add idempotency checks to all Elasticsearch migrations 2025-11-26 02:15:02 +00:00
2025_08_31_221648_create_tasks_index.php fix: Add idempotency checks to all Elasticsearch migrations 2025-11-26 02:15:02 +00:00
2025_08_31_221649_create_client_contacts_index.php fix: Add idempotency checks to all Elasticsearch migrations 2025-11-26 02:15:02 +00:00
2025_08_31_221650_create_vendor_contacts_index.php fix: Add idempotency checks to all Elasticsearch migrations 2025-11-26 02:15:02 +00:00
2025_08_31_221651_create_clients_index.php fix: Add idempotency checks to all Elasticsearch migrations 2025-11-26 02:15:02 +00:00