joselfonseca / lighthouse-graphql-passport-auth

Add GraphQL mutations to get tokens from passport for https://lighthouse-php.com/
https://lighthouse-php-auth.com/
MIT License
228 stars 56 forks source link

Migration failure on fresh install laravel 8 #141

Closed newtoniumx3 closed 3 years ago

newtoniumx3 commented 3 years ago
Migrating: 2014_10_12_000000_create_users_table
Migrated:  2014_10_12_000000_create_users_table (134.25ms)
Migrating: 2014_10_12_100000_create_password_resets_table
Migrated:  2014_10_12_100000_create_password_resets_table (93.87ms)
Migrating: 2019_08_19_000000_create_failed_jobs_table
Migrated:  2019_08_19_000000_create_failed_jobs_table (83.16ms)
Migrating: 2019_11_19_000000_update_social_provider_users_table

   Illuminate\Database\QueryException

  SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint (SQL: alter table `social_providers` add constraint `social_providers_user_id_foreign` foreign key (`user_id`) references `users` (`id`) on delete cascade)

  at vendor/laravel/framework/src/Illuminate/Database/Connection.php:678
    674▕         // If an exception occurs when attempting to run a query, we'll format the error
    675▕         // message to include the bindings with SQL, which will make this exception a
    676▕         // lot more helpful to the developer instead of just the database's errors.
    677▕         catch (Exception $e) {
  ➜ 678▕             throw new QueryException(
    679▕                 $query, $this->prepareBindings($bindings), $e
    680▕             );
    681▕         }
    682▕

      +31 vendor frames
  32  artisan:37
      Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
newtoniumx3 commented 3 years ago

Do I have to run a migration first before installing the package to then migrate again?

maximerassi commented 3 years ago

This should fix your issue

https://github.com/joselfonseca/lighthouse-graphql-passport-auth/pull/142/commits/127ed9451b4b9368efb0aa31340ded3c1b98f3d6

joselfonseca commented 3 years ago

You can publish the migration before running it and update it to match your needs.

https://lighthouse-php-auth.com/docs/installation/