{"id":1307,"date":"2023-11-29T10:31:38","date_gmt":"2023-11-29T10:31:38","guid":{"rendered":"https:\/\/www.devopssupport.in\/blog\/?p=1307"},"modified":"2023-11-29T10:31:39","modified_gmt":"2023-11-29T10:31:39","slug":"resolving-sqlstate42s22-column-not-found-1054-unknown-column-provider-in-field","status":"publish","type":"post","link":"https:\/\/www.devopssupport.in\/blog\/resolving-sqlstate42s22-column-not-found-1054-unknown-column-provider-in-field\/","title":{"rendered":"Resolving SQLSTATE[42S22]: Column not found: 1054 Unknown column &#8216;provider&#8217; in &#8216;field&#8217;"},"content":{"rendered":"\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"862\" height=\"312\" src=\"https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/11\/image-35.png\" alt=\"\" class=\"wp-image-1308\" srcset=\"https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/11\/image-35.png 862w, https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/11\/image-35-300x109.png 300w, https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/11\/image-35-768x278.png 768w, https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/11\/image-35-850x308.png 850w\" sizes=\"auto, (max-width: 862px) 100vw, 862px\" \/><\/figure>\n\n\n\n<p>The error indicates that there&#8217;s an attempt to access a column named &#8216;provider&#8217; in a database table, but this column doesn&#8217;t exist. Laravel Passport, starting from version 10.0, introduces support for multiple guard user providers, requiring the addition of a &#8216;provider&#8217; column to the &#8216;oauth_clients&#8217; database table.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Solution: Upgrading Passport and Adding the &#8216;provider&#8217; Column<\/h2>\n\n\n\n<p>To resolve this issue, you need to upgrade Passport to version 10.0 or later and add the &#8216;provider&#8217; column to the &#8216;oauth_clients&#8217; table. Here are the steps:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1. Upgrade Passport to Version 10.0<\/h3>\n\n\n\n<p>In your terminal, navigate to your Laravel project&#8217;s root directory and run the following Composer command to upgrade Passport:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>composer require laravel\/passport:^your version\r\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">2. Add the &#8216;provider&#8217; Column to the &#8216;oauth_clients&#8217; Table<\/h3>\n\n\n\n<p>After upgrading Passport, you need to add the &#8216;provider&#8217; column to the &#8216;oauth_clients&#8217; table. If you have not previously published the Passport migrations, you can manually add the column using a migration.<\/p>\n\n\n\n<p>Create a new migration using the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>php artisan make:migration add_provider_to_oauth_clients --table=oauth_clients\r\n<\/code><\/pre>\n\n\n\n<p>Open the generated migration file (located in the &#8216;database\/migrations&#8217; directory) and add the &#8216;provider&#8217; column definition:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>use Illuminate\\Database\\Migrations\\Migration;\r\nuse Illuminate\\Database\\Schema\\Blueprint;\r\nuse Illuminate\\Support\\Facades\\Schema;\r\n\r\nclass AddProviderToOauthClients extends Migration\r\n{\r\n    \/**\r\n     * Run the migrations.\r\n     *\r\n     * @return void\r\n     *\/\r\n    public function up()\r\n    {\r\n        Schema::table('oauth_clients', function (Blueprint $table) {\r\n            $table->string('provider')->after('secret')->nullable();\r\n        });\r\n    }\r\n\r\n    \/**\r\n     * Reverse the migrations.\r\n     *\r\n     * @return void\r\n     *\/\r\n    public function down()\r\n    {\r\n        Schema::table('oauth_clients', function (Blueprint $table) {\r\n            $table->dropColumn('provider');\r\n        });\r\n    }\r\n}\r\n<\/code><\/pre>\n\n\n\n<p>Run the migration to apply the changes:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>php artisan migrate\r\n<\/code><\/pre>\n\n\n\n<p>After completing these steps, retry the operation that resulted in the &#8216;Column not found: 1054 Unknown column &#8216;provider&#8217; in &#8216;field&#8221; error. The &#8216;provider&#8217; column should now exist in the &#8216;oauth_clients&#8217; table, resolving the issue.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The error indicates that there&#8217;s an attempt to access a column named &#8216;provider&#8217; in a database table, but this column doesn&#8217;t exist. Laravel Passport, starting from version&#8230; <\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1307","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/posts\/1307","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/comments?post=1307"}],"version-history":[{"count":1,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/posts\/1307\/revisions"}],"predecessor-version":[{"id":1309,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/posts\/1307\/revisions\/1309"}],"wp:attachment":[{"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/media?parent=1307"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/categories?post=1307"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/tags?post=1307"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}