webreinvent / vaahcms

VaahCMS is a laravel based open-source web application development platform shipped with a headless content management system (CMS).
https://vaah.dev/cms
MIT License
134 stars 22 forks source link

Getting error on migration run "Base table or view not found: 1146 Table 'vaahcms.vh_users' doesn't exist" #101

Closed bilaschandra closed 1 year ago

bilaschandra commented 1 year ago

I am getting the bellow error at the time of migration run from the command line and frontend http://127.0.0.1:8000/backend#/install/migrate. Both cases are getting the same error. How can I run the migration script?

PHP 8.1.14 MySQL 8.0.23

/var/www/html $ php artisan migrate:fresh
Dropped all tables successfully.
Migration table created successfully.
Migrating: 2019_12_14_000001_create_personal_access_tokens_table
Migrated:  2019_12_14_000001_create_personal_access_tokens_table (100.36ms)
Migrating: 2021_05_12_201856_add_designation_to_vh_users_and_vh_registrations_table

   Illuminate\Database\QueryException

  SQLSTATE[42S02]: Base table or view not found: 1146 Table 'vaahcms.vh_users' doesn't exist (SQL: alter table `vh_users` add `designation` varchar(200) null after `title`)

  at vendor/laravel/framework/src/Illuminate/Database/Connection.php:712
    708▕         // If an exception occurs when attempting to run a query, we'll format the error
    709▕         // message to include the bindings with SQL, which will make this exception a
    710▕         // lot more helpful to the developer instead of just the database's errors.
    711▕         catch (Exception $e) {
  ➜ 712▕             throw new QueryException(
    713▕                 $query, $this->prepareBindings($bindings), $e
    714▕             );
    715▕         }
    716▕     }

  • A table was not found: You might have forgotten to run your migrations. You can run your migrations using `php artisan migrate`.
    https://laravel.com/docs/master/migrations#running-migrations

      +9 vendor frames
  10  database/migrations/2021_05_12_201856_add_designation_to_vh_users_and_vh_registrations_table.php:19
      Illuminate\Support\Facades\Facade::__callStatic("table")

      +33 vendor frames
  44  artisan:37
      Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
themodernpk commented 1 year ago

It looks like all migrations of VaahCMS are not published or migrated, it may happen because of some file permissions, I guess. You can try the manual method to install VaahCMS, please refer:

https://docs.vaah.dev/vaahcms/installation.html#manual-download-installation

Or Publish all the migration using following command:

php artisan vendor:publish --provider="WebReinvent\VaahCms\VaahCmsServiceProvider" --tag=migrations  --force

And then follow the process at http://127.0.0.1:8000/backend#/install/migrate

themodernpk commented 1 year ago

@bilaschandra Is there anything else we can help you with?

bilaschandra commented 1 year ago

I ran the command but still, I am getting the same error. Here is the screenshot.

/var/www/html $ php artisan vendor:publish --provider="WebReinvent\VaahCms\VaahCmsServiceProvider" --tag=migrations  --force
Copied Directory [/vendor/webreinvent/vaahcms/Database/Migrations] To [/database/migrations]
Publishing complete.

ScreenShot Tool -20230123153233

themodernpk commented 1 year ago

@bilaschandra can you share the screenshot of your database/migrations folder?

bilaschandra commented 1 year ago

@bilaschandra can you share the screenshot of your database/migrations folder?

Screenshot 2023-01-23 163556

themodernpk commented 1 year ago

@bilaschandra that is the problem, I don't know the reason in your case, but you run

php artisan vendor:publish --provider="WebReinvent\VaahCms\VaahCmsServiceProvider" --tag=migrations  --force

it should move all the migrations from /vendor/webreinvent/vaahcms/Database/Migrations folder to /database/migrations.

You should check your folder permissions or manually copy or move all the migrations from /vendor/webreinvent/vaahcms/Database/Migrations folder to /database/migrations.

/database/migrations folder should have all the migration listed at: https://github.com/webreinvent/vaahcms/tree/1.x/Database/Migrations

bilaschandra commented 1 year ago

Thanks @themodernpk . Manually, I have moved all the migrations from /vendor/webreinvent/vaahcms/Database/Migrations folder to /database/migrations. Now it is working.

themodernpk commented 1 year ago

@bilaschandra thanks for the confirmation, closing the issue.