diff --git a/elastic/migrations/2025_08_31_221640_create_invoices_index.php b/elastic/migrations/2025_08_31_221640_create_invoices_index.php new file mode 100644 index 0000000000..aad798f900 --- /dev/null +++ b/elastic/migrations/2025_08_31_221640_create_invoices_index.php @@ -0,0 +1,89 @@ + [ + // Core invoice fields + 'id' => ['type' => 'keyword'], + 'name' => [ + 'type' => 'text', + 'analyzer' => 'standard' + ], + 'hashed_id' => ['type' => 'keyword'], + 'number' => ['type' => 'keyword'], + 'is_deleted' => ['type' => 'boolean'], + 'amount' => ['type' => 'float'], + 'balance' => ['type' => 'float'], + 'due_date' => ['type' => 'date'], + 'date' => ['type' => 'date'], + + // Custom fields + 'custom_value1' => ['type' => 'keyword'], + 'custom_value2' => ['type' => 'keyword'], + 'custom_value3' => ['type' => 'keyword'], + 'custom_value4' => ['type' => 'keyword'], + + // Additional fields + 'company_key' => ['type' => 'keyword'], + 'po_number' => ['type' => 'keyword'], + + // Line items + 'line_items' => [ + 'type' => 'nested', + 'properties' => [ + 'quantity' => ['type' => 'float'], + 'net_cost' => ['type' => 'float'], + 'cost' => ['type' => 'float'], + 'product_key' => ['type' => 'text', 'analyzer' => 'standard'], + 'product_cost' => ['type' => 'float'], + 'notes' => ['type' => 'text', 'analyzer' => 'standard'], + 'discount' => ['type' => 'float'], + 'is_amount_discount' => ['type' => 'boolean'], + 'tax_name1' => ['type' => 'keyword'], + 'tax_rate1' => ['type' => 'float'], + 'tax_name2' => ['type' => 'keyword'], + 'tax_rate2' => ['type' => 'float'], + 'tax_name3' => ['type' => 'keyword'], + 'tax_rate3' => ['type' => 'float'], + 'sort_id' => ['type' => 'keyword'], + 'line_total' => ['type' => 'float'], + 'gross_line_total' => ['type' => 'float'], + 'tax_amount' => ['type' => 'float'], + 'date' => ['type' => 'keyword'], + 'custom_value1' => ['type' => 'keyword'], + 'custom_value2' => ['type' => 'keyword'], + 'custom_value3' => ['type' => 'keyword'], + 'custom_value4' => ['type' => 'keyword'], + 'type_id' => ['type' => 'keyword'], + 'tax_id' => ['type' => 'keyword'], + 'task_id' => ['type' => 'keyword'], + 'expense_id' => ['type' => 'keyword'], + 'unit_code' => ['type' => 'keyword'], + ] + ], + ] + ]; + + Index::createRaw('invoices_v2', $mapping); + } + + /** + * Reverse the migration. + */ + public function down(): void + { + Index::dropIfExists('invoices_v2'); + } +} diff --git a/elastic/migrations/2025_08_31_221641_create_quotes_index.php b/elastic/migrations/2025_08_31_221641_create_quotes_index.php new file mode 100644 index 0000000000..64b88795b9 --- /dev/null +++ b/elastic/migrations/2025_08_31_221641_create_quotes_index.php @@ -0,0 +1,89 @@ + [ + // Core quote fields + 'id' => ['type' => 'keyword'], + 'name' => [ + 'type' => 'text', + 'analyzer' => 'standard' + ], + 'hashed_id' => ['type' => 'keyword'], + 'number' => ['type' => 'keyword'], + 'is_deleted' => ['type' => 'boolean'], + 'amount' => ['type' => 'float'], + 'balance' => ['type' => 'float'], + 'due_date' => ['type' => 'date'], + 'date' => ['type' => 'date'], + + // Custom fields + 'custom_value1' => ['type' => 'keyword'], + 'custom_value2' => ['type' => 'keyword'], + 'custom_value3' => ['type' => 'keyword'], + 'custom_value4' => ['type' => 'keyword'], + + // Additional fields + 'company_key' => ['type' => 'keyword'], + 'po_number' => ['type' => 'keyword'], + + // Line items + 'line_items' => [ + 'type' => 'nested', + 'properties' => [ + 'quantity' => ['type' => 'float'], + 'net_cost' => ['type' => 'float'], + 'cost' => ['type' => 'float'], + 'product_key' => ['type' => 'text', 'analyzer' => 'standard'], + 'product_cost' => ['type' => 'float'], + 'notes' => ['type' => 'text', 'analyzer' => 'standard'], + 'discount' => ['type' => 'float'], + 'is_amount_discount' => ['type' => 'boolean'], + 'tax_name1' => ['type' => 'keyword'], + 'tax_rate1' => ['type' => 'float'], + 'tax_name2' => ['type' => 'keyword'], + 'tax_rate2' => ['type' => 'float'], + 'tax_name3' => ['type' => 'keyword'], + 'tax_rate3' => ['type' => 'float'], + 'sort_id' => ['type' => 'keyword'], + 'line_total' => ['type' => 'float'], + 'gross_line_total' => ['type' => 'float'], + 'tax_amount' => ['type' => 'float'], + 'date' => ['type' => 'keyword'], + 'custom_value1' => ['type' => 'keyword'], + 'custom_value2' => ['type' => 'keyword'], + 'custom_value3' => ['type' => 'keyword'], + 'custom_value4' => ['type' => 'keyword'], + 'type_id' => ['type' => 'keyword'], + 'tax_id' => ['type' => 'keyword'], + 'task_id' => ['type' => 'keyword'], + 'expense_id' => ['type' => 'keyword'], + 'unit_code' => ['type' => 'keyword'], + ] + ], + ] + ]; + + Index::createRaw('quotes_v2', $mapping); + } + + /** + * Reverse the migration. + */ + public function down(): void + { + Index::dropIfExists('quotes_v2'); + } +} diff --git a/elastic/migrations/2025_08_31_221642_create_credits_index.php b/elastic/migrations/2025_08_31_221642_create_credits_index.php new file mode 100644 index 0000000000..ab95e05d40 --- /dev/null +++ b/elastic/migrations/2025_08_31_221642_create_credits_index.php @@ -0,0 +1,89 @@ + [ + // Core credit fields + 'id' => ['type' => 'keyword'], + 'name' => [ + 'type' => 'text', + 'analyzer' => 'standard' + ], + 'hashed_id' => ['type' => 'keyword'], + 'number' => ['type' => 'keyword'], + 'is_deleted' => ['type' => 'boolean'], + 'amount' => ['type' => 'float'], + 'balance' => ['type' => 'float'], + 'due_date' => ['type' => 'date'], + 'date' => ['type' => 'date'], + + // Custom fields + 'custom_value1' => ['type' => 'keyword'], + 'custom_value2' => ['type' => 'keyword'], + 'custom_value3' => ['type' => 'keyword'], + 'custom_value4' => ['type' => 'keyword'], + + // Additional fields + 'company_key' => ['type' => 'keyword'], + 'po_number' => ['type' => 'keyword'], + + // Line items + 'line_items' => [ + 'type' => 'nested', + 'properties' => [ + 'quantity' => ['type' => 'float'], + 'net_cost' => ['type' => 'float'], + 'cost' => ['type' => 'float'], + 'product_key' => ['type' => 'text', 'analyzer' => 'standard'], + 'product_cost' => ['type' => 'float'], + 'notes' => ['type' => 'text', 'analyzer' => 'standard'], + 'discount' => ['type' => 'float'], + 'is_amount_discount' => ['type' => 'boolean'], + 'tax_name1' => ['type' => 'keyword'], + 'tax_rate1' => ['type' => 'float'], + 'tax_name2' => ['type' => 'keyword'], + 'tax_rate2' => ['type' => 'float'], + 'tax_name3' => ['type' => 'keyword'], + 'tax_rate3' => ['type' => 'float'], + 'sort_id' => ['type' => 'keyword'], + 'line_total' => ['type' => 'float'], + 'gross_line_total' => ['type' => 'float'], + 'tax_amount' => ['type' => 'float'], + 'date' => ['type' => 'keyword'], + 'custom_value1' => ['type' => 'keyword'], + 'custom_value2' => ['type' => 'keyword'], + 'custom_value3' => ['type' => 'keyword'], + 'custom_value4' => ['type' => 'keyword'], + 'type_id' => ['type' => 'keyword'], + 'tax_id' => ['type' => 'keyword'], + 'task_id' => ['type' => 'keyword'], + 'expense_id' => ['type' => 'keyword'], + 'unit_code' => ['type' => 'keyword'], + ] + ], + ] + ]; + + Index::createRaw('credits_v2', $mapping); + } + + /** + * Reverse the migration. + */ + public function down(): void + { + Index::dropIfExists('credits_v2'); + } +} diff --git a/elastic/migrations/2025_08_31_221643_create_recurring_invoices_index.php b/elastic/migrations/2025_08_31_221643_create_recurring_invoices_index.php new file mode 100644 index 0000000000..06af6bc3f5 --- /dev/null +++ b/elastic/migrations/2025_08_31_221643_create_recurring_invoices_index.php @@ -0,0 +1,89 @@ + [ + // Core recurring invoice fields + 'id' => ['type' => 'keyword'], + 'name' => [ + 'type' => 'text', + 'analyzer' => 'standard' + ], + 'hashed_id' => ['type' => 'keyword'], + 'number' => ['type' => 'keyword'], + 'is_deleted' => ['type' => 'boolean'], + 'amount' => ['type' => 'float'], + 'balance' => ['type' => 'float'], + 'due_date' => ['type' => 'date'], + 'date' => ['type' => 'date'], + + // Custom fields + 'custom_value1' => ['type' => 'keyword'], + 'custom_value2' => ['type' => 'keyword'], + 'custom_value3' => ['type' => 'keyword'], + 'custom_value4' => ['type' => 'keyword'], + + // Additional fields + 'company_key' => ['type' => 'keyword'], + 'po_number' => ['type' => 'keyword'], + + // Line items + 'line_items' => [ + 'type' => 'nested', + 'properties' => [ + 'quantity' => ['type' => 'float'], + 'net_cost' => ['type' => 'float'], + 'cost' => ['type' => 'float'], + 'product_key' => ['type' => 'text', 'analyzer' => 'standard'], + 'product_cost' => ['type' => 'float'], + 'notes' => ['type' => 'text', 'analyzer' => 'standard'], + 'discount' => ['type' => 'float'], + 'is_amount_discount' => ['type' => 'boolean'], + 'tax_name1' => ['type' => 'keyword'], + 'tax_rate1' => ['type' => 'float'], + 'tax_name2' => ['type' => 'keyword'], + 'tax_rate2' => ['type' => 'float'], + 'tax_name3' => ['type' => 'keyword'], + 'tax_rate3' => ['type' => 'float'], + 'sort_id' => ['type' => 'keyword'], + 'line_total' => ['type' => 'float'], + 'gross_line_total' => ['type' => 'float'], + 'tax_amount' => ['type' => 'float'], + 'date' => ['type' => 'keyword'], + 'custom_value1' => ['type' => 'keyword'], + 'custom_value2' => ['type' => 'keyword'], + 'custom_value3' => ['type' => 'keyword'], + 'custom_value4' => ['type' => 'keyword'], + 'type_id' => ['type' => 'keyword'], + 'tax_id' => ['type' => 'keyword'], + 'task_id' => ['type' => 'keyword'], + 'expense_id' => ['type' => 'keyword'], + 'unit_code' => ['type' => 'keyword'], + ] + ], + ] + ]; + + Index::createRaw('recurring_invoices_v2', $mapping); + } + + /** + * Reverse the migration. + */ + public function down(): void + { + Index::dropIfExists('recurring_invoices_v2'); + } +} diff --git a/elastic/migrations/2025_08_31_221644_create_purchase_orders_index.php b/elastic/migrations/2025_08_31_221644_create_purchase_orders_index.php new file mode 100644 index 0000000000..6b765a6e16 --- /dev/null +++ b/elastic/migrations/2025_08_31_221644_create_purchase_orders_index.php @@ -0,0 +1,89 @@ + [ + // Core purchase order fields + 'id' => ['type' => 'keyword'], + 'name' => [ + 'type' => 'text', + 'analyzer' => 'standard' + ], + 'hashed_id' => ['type' => 'keyword'], + 'number' => ['type' => 'keyword'], + 'is_deleted' => ['type' => 'boolean'], + 'amount' => ['type' => 'float'], + 'balance' => ['type' => 'float'], + 'due_date' => ['type' => 'date'], + 'date' => ['type' => 'date'], + + // Custom fields + 'custom_value1' => ['type' => 'keyword'], + 'custom_value2' => ['type' => 'keyword'], + 'custom_value3' => ['type' => 'keyword'], + 'custom_value4' => ['type' => 'keyword'], + + // Additional fields + 'company_key' => ['type' => 'keyword'], + 'po_number' => ['type' => 'keyword'], + + // Line items + 'line_items' => [ + 'type' => 'nested', + 'properties' => [ + 'quantity' => ['type' => 'float'], + 'net_cost' => ['type' => 'float'], + 'cost' => ['type' => 'float'], + 'product_key' => ['type' => 'text', 'analyzer' => 'standard'], + 'product_cost' => ['type' => 'float'], + 'notes' => ['type' => 'text', 'analyzer' => 'standard'], + 'discount' => ['type' => 'float'], + 'is_amount_discount' => ['type' => 'boolean'], + 'tax_name1' => ['type' => 'keyword'], + 'tax_rate1' => ['type' => 'float'], + 'tax_name2' => ['type' => 'keyword'], + 'tax_rate2' => ['type' => 'float'], + 'tax_name3' => ['type' => 'keyword'], + 'tax_rate3' => ['type' => 'float'], + 'sort_id' => ['type' => 'keyword'], + 'line_total' => ['type' => 'float'], + 'gross_line_total' => ['type' => 'float'], + 'tax_amount' => ['type' => 'float'], + 'date' => ['type' => 'keyword'], + 'custom_value1' => ['type' => 'keyword'], + 'custom_value2' => ['type' => 'keyword'], + 'custom_value3' => ['type' => 'keyword'], + 'custom_value4' => ['type' => 'keyword'], + 'type_id' => ['type' => 'keyword'], + 'tax_id' => ['type' => 'keyword'], + 'task_id' => ['type' => 'keyword'], + 'expense_id' => ['type' => 'keyword'], + 'unit_code' => ['type' => 'keyword'], + ] + ], + ] + ]; + + Index::createRaw('purchase_orders_v2', $mapping); + } + + /** + * Reverse the migration. + */ + public function down(): void + { + Index::dropIfExists('purchase_orders_v2'); + } +} diff --git a/elastic/migrations/2025_08_31_221645_create_vendors_index.php b/elastic/migrations/2025_08_31_221645_create_vendors_index.php new file mode 100644 index 0000000000..f38f87cfdf --- /dev/null +++ b/elastic/migrations/2025_08_31_221645_create_vendors_index.php @@ -0,0 +1,72 @@ + [ + // Core vendor fields + 'id' => ['type' => 'keyword'], + 'name' => [ + 'type' => 'text', + 'analyzer' => 'standard' + ], + 'is_deleted' => ['type' => 'boolean'], + 'hashed_id' => ['type' => 'keyword'], + 'number' => ['type' => 'keyword'], + 'id_number' => ['type' => 'keyword'], + 'vat_number' => ['type' => 'keyword'], + + // Contact information + 'phone' => ['type' => 'keyword'], + + // Address fields + 'address1' => ['type' => 'keyword'], + 'address2' => ['type' => 'keyword'], + 'city' => ['type' => 'keyword'], + 'state' => ['type' => 'keyword'], + 'postal_code' => ['type' => 'keyword'], + + // Additional fields + 'website' => ['type' => 'keyword'], + 'private_notes' => [ + 'type' => 'text', + 'analyzer' => 'standard' + ], + 'public_notes' => [ + 'type' => 'text', + 'analyzer' => 'standard' + ], + + // Custom fields + 'custom_value1' => ['type' => 'keyword'], + 'custom_value2' => ['type' => 'keyword'], + 'custom_value3' => ['type' => 'keyword'], + 'custom_value4' => ['type' => 'keyword'], + + // Company + 'company_key' => ['type' => 'keyword'], + ] + ]; + + Index::createRaw('vendors_v2', $mapping); + } + + /** + * Reverse the migration. + */ + public function down(): void + { + Index::dropIfExists('vendors_v2'); + } +} diff --git a/elastic/migrations/2025_08_31_221646_create_expenses_index.php b/elastic/migrations/2025_08_31_221646_create_expenses_index.php new file mode 100644 index 0000000000..d847e95107 --- /dev/null +++ b/elastic/migrations/2025_08_31_221646_create_expenses_index.php @@ -0,0 +1,71 @@ + [ + // Core expense fields + 'id' => ['type' => 'keyword'], + 'name' => [ + 'type' => 'text', + 'analyzer' => 'standard' + ], + 'is_deleted' => ['type' => 'boolean'], + 'hashed_id' => ['type' => 'keyword'], + 'number' => ['type' => 'keyword'], + 'amount' => ['type' => 'float'], + 'tax_amount' => ['type' => 'float'], + 'tax_name1' => ['type' => 'keyword'], + 'tax_rate1' => ['type' => 'float'], + 'tax_name2' => ['type' => 'keyword'], + 'tax_rate2' => ['type' => 'float'], + 'tax_name3' => ['type' => 'keyword'], + 'tax_rate3' => ['type' => 'float'], + 'date' => ['type' => 'date'], + 'payment_date' => ['type' => 'date'], + + // Custom fields + 'custom_value1' => ['type' => 'keyword'], + 'custom_value2' => ['type' => 'keyword'], + 'custom_value3' => ['type' => 'keyword'], + 'custom_value4' => ['type' => 'keyword'], + + // Additional fields + 'company_key' => ['type' => 'keyword'], + 'category_id' => ['type' => 'keyword'], + 'vendor_id' => ['type' => 'keyword'], + 'client_id' => ['type' => 'keyword'], + 'project_id' => ['type' => 'keyword'], + 'private_notes' => [ + 'type' => 'text', + 'analyzer' => 'standard' + ], + 'public_notes' => [ + 'type' => 'text', + 'analyzer' => 'standard' + ], + ] + ]; + + Index::createRaw('expenses_v2', $mapping); + } + + /** + * Reverse the migration. + */ + public function down(): void + { + Index::dropIfExists('expenses_v2'); + } +} diff --git a/elastic/migrations/2025_08_31_221647_create_projects_index.php b/elastic/migrations/2025_08_31_221647_create_projects_index.php new file mode 100644 index 0000000000..6cc21c0f84 --- /dev/null +++ b/elastic/migrations/2025_08_31_221647_create_projects_index.php @@ -0,0 +1,67 @@ + [ + // Core project fields + 'id' => ['type' => 'keyword'], + 'name' => [ + 'type' => 'text', + 'analyzer' => 'standard' + ], + 'is_deleted' => ['type' => 'boolean'], + 'hashed_id' => ['type' => 'keyword'], + 'number' => ['type' => 'keyword'], + 'description' => [ + 'type' => 'text', + 'analyzer' => 'standard' + ], + 'budgeted_hours' => ['type' => 'float'], + 'task_rate' => ['type' => 'float'], + 'due_date' => ['type' => 'date'], + 'start_date' => ['type' => 'date'], + + // Custom fields + 'custom_value1' => ['type' => 'keyword'], + 'custom_value2' => ['type' => 'keyword'], + 'custom_value3' => ['type' => 'keyword'], + 'custom_value4' => ['type' => 'keyword'], + + // Additional fields + 'company_key' => ['type' => 'keyword'], + 'client_id' => ['type' => 'keyword'], + 'assigned_user_id' => ['type' => 'keyword'], + 'private_notes' => [ + 'type' => 'text', + 'analyzer' => 'standard' + ], + 'public_notes' => [ + 'type' => 'text', + 'analyzer' => 'standard' + ], + ] + ]; + + Index::createRaw('projects_v2', $mapping); + } + + /** + * Reverse the migration. + */ + public function down(): void + { + Index::dropIfExists('projects_v2'); + } +} diff --git a/elastic/migrations/2025_08_31_221648_create_tasks_index.php b/elastic/migrations/2025_08_31_221648_create_tasks_index.php new file mode 100644 index 0000000000..30aeedf806 --- /dev/null +++ b/elastic/migrations/2025_08_31_221648_create_tasks_index.php @@ -0,0 +1,71 @@ + [ + // Core task fields + 'id' => ['type' => 'keyword'], + 'name' => [ + 'type' => 'text', + 'analyzer' => 'standard' + ], + 'is_deleted' => ['type' => 'boolean'], + 'hashed_id' => ['type' => 'keyword'], + 'number' => ['type' => 'keyword'], + 'description' => [ + 'type' => 'text', + 'analyzer' => 'standard' + ], + 'rate' => ['type' => 'float'], + 'hours' => ['type' => 'float'], + 'due_date' => ['type' => 'date'], + 'start_date' => ['type' => 'date'], + + // Custom fields + 'custom_value1' => ['type' => 'keyword'], + 'custom_value2' => ['type' => 'keyword'], + 'custom_value3' => ['type' => 'keyword'], + 'custom_value4' => ['type' => 'keyword'], + + // Additional fields + 'company_key' => ['type' => 'keyword'], + 'client_id' => ['type' => 'keyword'], + 'project_id' => ['type' => 'keyword'], + 'assigned_user_id' => ['type' => 'keyword'], + 'status_id' => ['type' => 'keyword'], + 'private_notes' => [ + 'type' => 'text', + 'analyzer' => 'standard' + ], + 'public_notes' => [ + 'type' => 'text', + 'analyzer' => 'standard' + ], + ] + ]; + + Index::createRaw('tasks_v2', $mapping); + } + + /** + * Reverse the migration. + */ + public function down(): void + { + Index::dropIfExists('tasks_v2'); + } +} + + diff --git a/elastic/migrations/2025_08_31_221649_create_client_contacts_index.php b/elastic/migrations/2025_08_31_221649_create_client_contacts_index.php new file mode 100644 index 0000000000..4d19002bd4 --- /dev/null +++ b/elastic/migrations/2025_08_31_221649_create_client_contacts_index.php @@ -0,0 +1,56 @@ + [ + // Core client contact fields + 'id' => ['type' => 'keyword'], + 'name' => [ + 'type' => 'text', + 'analyzer' => 'standard' + ], + 'is_deleted' => ['type' => 'boolean'], + 'hashed_id' => ['type' => 'keyword'], + 'first_name' => ['type' => 'keyword'], + 'last_name' => ['type' => 'keyword'], + 'email' => ['type' => 'keyword'], + 'phone' => ['type' => 'keyword'], + 'is_primary' => ['type' => 'boolean'], + + // Custom fields + 'custom_value1' => ['type' => 'keyword'], + 'custom_value2' => ['type' => 'keyword'], + 'custom_value3' => ['type' => 'keyword'], + 'custom_value4' => ['type' => 'keyword'], + + // Additional fields + 'company_key' => ['type' => 'keyword'], + 'client_id' => ['type' => 'keyword'], + 'send_email' => ['type' => 'boolean'], + 'last_login' => ['type' => 'date'], + ] + ]; + + Index::createRaw('client_contacts_v2', $mapping); + } + + /** + * Reverse the migration. + */ + public function down(): void + { + Index::dropIfExists('client_contacts_v2'); + } +} diff --git a/elastic/migrations/2025_08_31_221650_create_vendor_contacts_index.php b/elastic/migrations/2025_08_31_221650_create_vendor_contacts_index.php new file mode 100644 index 0000000000..cc12b50201 --- /dev/null +++ b/elastic/migrations/2025_08_31_221650_create_vendor_contacts_index.php @@ -0,0 +1,56 @@ + [ + // Core vendor contact fields + 'id' => ['type' => 'keyword'], + 'name' => [ + 'type' => 'text', + 'analyzer' => 'standard' + ], + 'is_deleted' => ['type' => 'boolean'], + 'hashed_id' => ['type' => 'keyword'], + 'first_name' => ['type' => 'keyword'], + 'last_name' => ['type' => 'keyword'], + 'email' => ['type' => 'keyword'], + 'phone' => ['type' => 'keyword'], + 'is_primary' => ['type' => 'boolean'], + + // Custom fields + 'custom_value1' => ['type' => 'keyword'], + 'custom_value2' => ['type' => 'keyword'], + 'custom_value3' => ['type' => 'keyword'], + 'custom_value4' => ['type' => 'keyword'], + + // Additional fields + 'company_key' => ['type' => 'keyword'], + 'vendor_id' => ['type' => 'keyword'], + 'send_email' => ['type' => 'boolean'], + 'last_login' => ['type' => 'date'], + ] + ]; + + Index::createRaw('vendor_contacts_v2', $mapping); + } + + /** + * Reverse the migration. + */ + public function down(): void + { + Index::dropIfExists('vendor_contacts_v2'); + } +} diff --git a/elastic/migrations/2025_08_31_221651_create_clients_index.php b/elastic/migrations/2025_08_31_221651_create_clients_index.php new file mode 100644 index 0000000000..c18b69bbed --- /dev/null +++ b/elastic/migrations/2025_08_31_221651_create_clients_index.php @@ -0,0 +1,146 @@ + [ + // Core client fields + 'id' => ['type' => 'keyword'], + 'name' => [ + 'type' => 'text', + 'analyzer' => 'standard' + ], + 'hashed_id' => ['type' => 'keyword'], + 'number' => ['type' => 'keyword'], + 'is_deleted' => ['type' => 'boolean'], + 'user_id' => ['type' => 'keyword'], + 'assigned_user_id' => ['type' => 'keyword'], + 'company_id' => ['type' => 'keyword'], + + // Contact and business information + 'website' => ['type' => 'keyword'], + 'phone' => ['type' => 'keyword'], + 'client_hash' => ['type' => 'keyword'], + 'routing_id' => ['type' => 'keyword'], + 'vat_number' => ['type' => 'keyword'], + 'id_number' => ['type' => 'keyword'], + 'classification' => ['type' => 'keyword'], + + // Financial information + 'balance' => ['type' => 'float'], + 'paid_to_date' => ['type' => 'float'], + 'credit_balance' => ['type' => 'float'], + 'payment_balance' => ['type' => 'float'], + + // Address information + 'address1' => [ + 'type' => 'text', + 'analyzer' => 'standard' + ], + 'address2' => [ + 'type' => 'text', + 'analyzer' => 'standard' + ], + 'city' => ['type' => 'keyword'], + 'state' => ['type' => 'keyword'], + 'postal_code' => ['type' => 'keyword'], + 'country_id' => ['type' => 'keyword'], + + // Shipping address + 'shipping_address1' => [ + 'type' => 'text', + 'analyzer' => 'standard' + ], + 'shipping_address2' => [ + 'type' => 'text', + 'analyzer' => 'standard' + ], + 'shipping_city' => ['type' => 'keyword'], + 'shipping_state' => ['type' => 'keyword'], + 'shipping_postal_code' => ['type' => 'keyword'], + 'shipping_country_id' => ['type' => 'keyword'], + + // Classification and industry + 'industry_id' => ['type' => 'keyword'], + 'size_id' => ['type' => 'keyword'], + 'group_settings_id' => ['type' => 'keyword'], + + // Custom fields + 'custom_value1' => [ + 'type' => 'text', + 'analyzer' => 'standard' + ], + 'custom_value2' => [ + 'type' => 'text', + 'analyzer' => 'standard' + ], + 'custom_value3' => [ + 'type' => 'text', + 'analyzer' => 'standard' + ], + 'custom_value4' => [ + 'type' => 'text', + 'analyzer' => 'standard' + ], + + // Notes and content + 'private_notes' => [ + 'type' => 'text', + 'analyzer' => 'standard' + ], + 'public_notes' => [ + 'type' => 'text', + 'analyzer' => 'standard' + ], + 'display_name' => [ + 'type' => 'text', + 'analyzer' => 'standard' + ], + + // Tax and invoice settings + 'is_tax_exempt' => ['type' => 'boolean'], + 'has_valid_vat_number' => ['type' => 'boolean'], + 'tax_info' => ['type' => 'object'], + 'e_invoice' => ['type' => 'object'], + + // Settings and configuration + 'settings' => ['type' => 'object'], + 'sync' => ['type' => 'object'], + + // Timestamps + 'last_login' => ['type' => 'date'], + 'created_at' => ['type' => 'date'], + 'updated_at' => ['type' => 'date'], + 'archived_at' => ['type' => 'date'], + + // Company key for multi-tenancy + 'company_key' => ['type' => 'keyword'], + ] + ]; + + Index::createRaw('clients_v2', $mapping); + } + + /** + * Reverse the migration. + */ + public function down(): void + { + Index::dropIfExists('clients_v2'); + } +} + + + +