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

Error on create_permissions_table migration #386

Open
zaidpirwani opened this issue May 19, 2024 · 1 comment
Open

Error on create_permissions_table migration #386

zaidpirwani opened this issue May 19, 2024 · 1 comment

Comments

@zaidpirwani
Copy link

Hello,

When I clone my project to a new dev machine and run migrations (fresh, no database)

I get error on create_permissions_table migration file

2024_05_18_145302_create_permission_tables ..................... 2s FAIL

   Error

  Call to a member function prepare() on null

  at vendor/laravel/framework/src/Illuminate/Database/Connection.php:592
    588▕
    589▕             // For update or delete statements, we want to get the number of rows affected
    590▕             // by the statement and return that back to the developer. We'll first need
    591▕             // to execute the statement and then we'll use PDO to fetch the affected.
  ➜ 592▕             $statement = $this->getPdo()->prepare($query);
    593▕
    594▕             $this->bindValues($statement, $this->prepareBindings($bindings));
    595▕
    596▕             $statement->execute();

      +7 vendor frames

  8   database/migrations/2024_05_18_145302_create_permission_tables.php:118
      Illuminate\Cache\Repository::forget()
      +26 vendor frames

  35  artisan:13
      Illuminate\Foundation\Application::handleCommand()

zaid@HO-IT-ZAID:~/LaravelQuiz$

I tried to reproduce it with a new laravel / filament / filament shield project - the error came up once and then didnt - I was trying migration again and again with new db etc.

I am using Ubuntu 24.04 on WSL on Windows 11
I have tried both sqlite and mysql databases

If I dont run create_permissions_table migration and run everything else and THEN run create_permissions_table migration it works and no error is thrown.

zaid@HO-IT-ZAID:~/LaravelQuiz$ php artisan migrate

   WARN  The database 'quiz' does not exist on the 'mysql' connection.

 ┌ Would you like to create it? ────────────────────────────────┐
 │ Yes                                                          │
 └──────────────────────────────────────────────────────────────┘

   INFO  Preparing database.

  Creating migration table ................................. 125.35ms DONE

   INFO  Running migrations.

  0001_01_01_000000_create_users_table ..................... 546.10ms DONE
  0001_01_01_000001_create_cache_table ..................... 200.73ms DONE
  0001_01_01_000002_create_jobs_table ...................... 517.93ms DONE
  2024_05_05_072256_create_notifications_table ............. 180.75ms DONE
  2024_05_05_072314_create_imports_table ................... 378.77ms DONE
  2024_05_05_072315_create_exports_table ................... 356.30ms DONE
  2024_05_05_072316_create_failed_import_rows_table ........ 370.50ms DONE
  2024_05_05_083927_create_quizzes_table ................... 382.30ms DONE
  2024_05_05_083928_create_questions_table ................. 483.25ms DONE
  2024_05_05_083929_create_answers_table ................... 476.52ms DONE
  2024_05_07_132936_create_submissions_table ............... 433.45ms DONE
  2024_05_07_192936_create_entries_table ......................... 2s DONE
  2024_05_09_173442_update_submissions_table ............... 121.93ms DONE
  2024_05_09_180235_update_quizzes_table ................... 148.43ms DONE
  2024_05_10_095602_add_user_id_to_quiz_questions_table .......... 1s DONE
  2024_05_10_101214_update_entries_table ................... 411.47ms DONE
  2024_05_11_103652_create_telescope_entries_table ......... 913.60ms DONE
  2024_05_12_120655_update_submissions_table_add_nullables . 313.89ms DONE

zaid@HO-IT-ZAID:~/LaravelQuiz$

zaid@HO-IT-ZAID:~/LaravelQuiz$ php artisan migrate

   INFO  Running migrations.

  2024_05_18_145302_create_permission_tables ..................... 2s DONE

zaid@HO-IT-ZAID:~/LaravelQuiz$

in this case, the refresh migrate also works - once if the create_permissions_table works, then if I refresh - it works again

zaid@HO-IT-ZAID:~/LaravelQuiz$ php artisan migrate:refresh

   INFO  Rolling back migrations.

  2024_05_18_145302_create_permission_tables ............... 435.37ms DONE
  2024_05_12_120655_update_submissions_table_add_nullables ... 0.26ms DONE
  2024_05_11_103652_create_telescope_entries_table ......... 248.67ms DONE
  2024_05_10_101214_update_entries_table ..................... 0.18ms DONE
  2024_05_10_095602_add_user_id_to_quiz_questions_table .... 799.49ms DONE
  2024_05_09_180235_update_quizzes_table ................... 237.40ms DONE
  2024_05_09_173442_update_submissions_table ............... 108.57ms DONE
  2024_05_07_192936_create_entries_table ................... 106.22ms DONE
  2024_05_07_132936_create_submissions_table ................ 86.51ms DONE
  2024_05_05_083929_create_answers_table .................... 85.04ms DONE
  2024_05_05_083928_create_questions_table .................. 73.64ms DONE
  2024_05_05_083927_create_quizzes_table .................... 79.68ms DONE
  2024_05_05_072316_create_failed_import_rows_table ......... 79.72ms DONE
  2024_05_05_072315_create_exports_table ................... 130.24ms DONE
  2024_05_05_072314_create_imports_table .................... 95.08ms DONE
  2024_05_05_072256_create_notifications_table .............. 92.69ms DONE
  0001_01_01_000002_create_jobs_table ...................... 257.62ms DONE
  0001_01_01_000001_create_cache_table ..................... 181.17ms DONE
  0001_01_01_000000_create_users_table ..................... 276.56ms DONE


   INFO  Running migrations.

  0001_01_01_000000_create_users_table ..................... 701.34ms DONE
  0001_01_01_000001_create_cache_table ..................... 303.48ms DONE
  0001_01_01_000002_create_jobs_table ...................... 642.72ms DONE
  2024_05_05_072256_create_notifications_table ............. 278.38ms DONE
  2024_05_05_072314_create_imports_table ................... 460.44ms DONE
  2024_05_05_072315_create_exports_table ................... 481.92ms DONE
  2024_05_05_072316_create_failed_import_rows_table ........ 431.19ms DONE
  2024_05_05_083927_create_quizzes_table ................... 473.56ms DONE
  2024_05_05_083928_create_questions_table ................. 433.55ms DONE
  2024_05_05_083929_create_answers_table ................... 445.00ms DONE
  2024_05_07_132936_create_submissions_table ............... 461.33ms DONE
  2024_05_07_192936_create_entries_table ......................... 1s DONE
  2024_05_09_173442_update_submissions_table ............... 117.57ms DONE
  2024_05_09_180235_update_quizzes_table ................... 133.33ms DONE
  2024_05_10_095602_add_user_id_to_quiz_questions_table .......... 1s DONE
  2024_05_10_101214_update_entries_table ................... 405.84ms DONE
  2024_05_11_103652_create_telescope_entries_table ............... 1s DONE
  2024_05_12_120655_update_submissions_table_add_nullables . 378.84ms DONE
  2024_05_18_145302_create_permission_tables ..................... 2s DONE

zaid@HO-IT-ZAID:~/LaravelQuiz$

I will try to give proper reproduction steps, but if there is anything I can do to fix this, would be great - its an inconvinience, as I can still run it - just that doesnt work on first run and need to rename create_permissions_table migration, then run all my migrations first and then run the create_permissions_table later after renaming it back

@zaidpirwani
Copy link
Author

commenting the following lines results in permissions migrations going smoothly

//        app('cache')
//            ->store(config('permission.cache.store') != 'default' ? config('permission.cache.store') : null)
//            ->forget(config('permission.cache.key'));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant