-
Notifications
You must be signed in to change notification settings - Fork 779
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
Upgrade Guide assumes Migration Customization #1264
Comments
Thanks. We've tried clarifying that you should manually add this column when you haven't published the migrations. |
@driesvints Thanks for the update, but unfortunately I don't think it's quite right (apart from the typos). There are two cases:
And there are two paths:
Case 1 will always cause a problem, because the deployed database will be inconsistent with the Only case 2 has a safe solution. Adding the migration that adds the column will solve the |
PS: The only safe solution for both cases and both paths would be a conditional migration that only adds the column if it doesn't exist. |
@caugner have you read the actual upgrade guide? We changed it again after the pr. |
@driesvints Indeed I had only looked at the referenced PR.
To me it seems like this suggested manual migration defeats the purpose of the migrations, but I guess there is no better solution in sight (like adding a conditional migration)? |
@caugner the OP of the PR should indeed have created a new migration. This is a bit unfortunate. We'll try to watch over this more carefully in the future. |
If anyone else needs it, here is the migration I am using to go from v8 to v9: (postgres) <?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class UpgradeLaravelPassportToNine extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
// https://github.com/laravel/passport/issues/1264#issuecomment-626745261
// unpublished migration changed in laravel/passport 9, only add this column if it's missing:
$hasProviderColumn = \Illuminate\Support\Facades\DB::table('information_schema.columns')
->select('column_name')
->where('table_name', '=', 'oauth_clients')
->where('column_name', '=', 'provider')
->exists();
if (!$hasProviderColumn) {
Schema::table('oauth_clients', function (Blueprint $table) {
// https://github.com/laravel/passport/blob/master/UPGRADE.md#support-for-multiple-guards
$table->string('provider')->after('secret')->nullable();
});
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('oauth_clients', function (Blueprint $table) {
$table->dropColumn('provider');
});
}
} |
The solution from @AlbinoDrought worked great, but our tests are using sqlite which does not have an if(!Schema::hasColumn('oauth_clients','provider')) {
Schema::table('oauth_clients', function (Blueprint $table) {
// https://github.com/laravel/passport/blob/master/UPGRADE.md#support-for-multiple-guards
$table->string('provider')->after('secret')->nullable();
});
} |
Description:
The Upgrade Guide explains in the Support For Multiple Guards section that a
provider
column must be added to theoauth_clients
database table.However, the migration provided only works if Migration Customization is used and
php artisan vendor:publish --tag=passport-migrations
was executed prior to the update.Otherwise, the migration will fail on fresh installations, because the column is already introduced by the (updated) default migration.
Steps To Reproduce:
composer require laravel/passport:^8
php artisan migrate
composer require laravel/passport:^9
php artisan make:migration PassportUpgradeTo9Dot0
php artisan migrate
(works)php artisan migrate:fresh
(fails)The text was updated successfully, but these errors were encountered: