diff --git a/database/migrations/2024_06_05_155321_update_stored_namespace.php b/database/migrations/2024_06_05_155321_update_stored_namespace.php new file mode 100644 index 00000000..372ed7a1 --- /dev/null +++ b/database/migrations/2024_06_05_155321_update_stored_namespace.php @@ -0,0 +1,44 @@ +replaceModelTypes('InvoiceShelf', 'App'); + $this->replaceModelTypes('Crater', 'App'); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + $this->replaceModelTypes('App', 'InvoiceShelf'); + } + + /** + * Replace model types in the specified tables. + */ + private function replaceModelTypes(string $from, string $to): void + { + $mappings = [ + 'media' => 'model_type', + 'email_logs' => 'mailable_type', + 'notifications' => 'notifiable_type', + 'personal_access_tokens' => 'tokenable_type', + 'custom_field_values' => 'custom_field_valuable_type', + 'abilities' => 'entity_type', + 'assigned_roles' => 'entity_type', + ]; + + foreach ($mappings as $table => $column) { + DB::table($table)->update([$column => DB::raw("REPLACE($column, '$from', '$to')")]); + } + } +};