Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migration fails with latest version of Laravel (12.x) and Nova (5.3.1) #6774

Open
jasonkaplan79 opened this issue Mar 10, 2025 · 1 comment
Labels
needs more info More information is required

Comments

@jasonkaplan79
Copy link

  • Laravel Version: 12.0
  • Nova Version: 5.3.1
  • PHP Version: 8
  • Database Driver & Version: MySQL
  • Operating System and Version: Mac
  • Browser type and version: Chrome
  • Reproduction Repository: https://github.com/###/###

Description:

Detailed steps to reproduce the issue on a fresh Nova installation:

I am seeing an error in my migration (I am using the latest version of Laravel: v12, and Nova: v5.3.1) :

`php artisan migrate:fresh --seed`
 
2018_01_01_000000_create_action_events_table ......................................................................................... 0.10ms FAIL

   Error 

  Call to a member function getKeyType() on null

  at vendor/laravel/framework/src/Illuminate/Database/Schema/Blueprint.php:1032
    1028▕         }
    1029▕ 
    1030▕         $column = $column ?: $model->getForeignKey();
    1031▕ 
  ➜ 1032▕         if ($model->getKeyType() === 'int') {
    1033▕             return $this->foreignId($column)
    1034▕                 ->table($model->getTable())
    1035▕                 ->referencesModelColumn($model->getKeyName());
    1036▕         }

  1   _LOCAL_PACKAGES/laravel_nova_package/database/migrations/2018_01_01_000000_create_action_events_table.php:21
      Illuminate\Database\Schema\Blueprint::foreignIdFor("user_id")
      +4 vendor frames 

  6   _LOCAL_PACKAGES/laravel_nova_package/database/migrations/2018_01_01_000000_create_action_events_table.php:18
      Illuminate\Support\Facades\Facade::__callStatic("create")

This is the change I needed to make to fix the problem:

database/migrations/2018_01_01_000000_create_action_events_table.php

@@ -18,7 +18,7 @@ public function up()

     Schema::create('action_events', function (Blueprint $table) {
         $table->id();
         $table->char('batch_id', 36);
- $table->foreignIdFor(Util::userModel(), 'user_id')->index();
+ $table->foreignIdFor(\App\Models\User::class, 'user_id')->index();
         $table->string('name');
         $table->morphs('actionable');
         $table->morphs('target');   

If this looks good to you, can this be incorporated in Nova?

@crynobone
Copy link
Member

Unable to reproduce the issue, please provide full reproducing repository based on fresh installation as suggested in the bug report template (or you can refer to https://github.com/nova-issues for example)

@crynobone crynobone added the needs more info More information is required label Mar 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs more info More information is required
Projects
None yet
Development

No branches or pull requests

2 participants