Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

cxbdia's avatar

Import record - change table names

I want to use the import records functionality mentioned here: https://filamentphp.com/docs/3.x/panels/resources/creating-records#importing-resource-records

Although, I want to prefix the two tables used in the import functionality in filament:

  1. imports -> mvl_imports
  2. failed_import_rows -> mvl_failed_import_rows

What all changes I need to make in order for the import to work successfully.

0 likes
2 replies
LaryAI's avatar
Level 58

To change the table names used by Filament's import functionality, you will need to perform a few steps. Here's a solution that should help you achieve your goal:

  1. Publish Filament's Migration Files: First, you need to publish the migration files for the import tables to your application so that you can modify them.

    php artisan vendor:publish --tag="filament-migrations"
    
  2. Rename the Tables in the Migration Files: Locate the migration files for the imports and failed_import_rows tables in your database/migrations directory. Rename the tables within these migration files to mvl_imports and mvl_failed_import_rows respectively.

    For example, in the imports table migration:

    Schema::create('mvl_imports', function (Blueprint $table) {
        // ...
    });
    

    And in the failed_import_rows table migration:

    Schema::create('mvl_failed_import_rows', function (Blueprint $table) {
        // ...
    });
    
  3. Update the Model Table Names: If Filament uses Eloquent models for these tables, you will need to update the $table property in each model to reflect the new table names.

    For the Import model:

    class Import extends Model
    {
        protected $table = 'mvl_imports';
        // ...
    }
    

    For the FailedImportRow model:

    class FailedImportRow extends Model
    {
        protected $table = 'mvl_failed_import_rows';
        // ...
    }
    
  4. Run the Migrations: After updating the migration files, run the migrations to create the new tables with the correct names.

    php artisan migrate
    
  5. Update Filament Configuration (if necessary): If Filament provides a configuration file where these table names are referenced, you will need to publish the configuration file and update the table names there as well.

    php artisan vendor:publish --tag="filament-config"
    

    Then, in the published configuration file (usually config/filament.php), update the table names:

    'imports' => [
        'table' => 'mvl_imports',
        // ...
    ],
    'failed_import_rows' => [
        'table' => 'mvl_failed_import_rows',
        // ...
    ],
    
  6. Review Any Custom Code: If you have any custom code that references the original table names, make sure to update those references to the new table names.

By following these steps, you should be able to successfully change the table names used by Filament's import functionality to mvl_imports and mvl_failed_import_rows. Make sure to test the import functionality thoroughly after making these changes to ensure everything is working as expected.

cxbdia's avatar

This did not work, any help here would be appreciated. I get this error: Base table or view not found: 1146 Table 'imports' doesn't exist

Please or to participate in this conversation.