Laravel Migration: Base Table Or View Already Exists
We're using Laravel (5.8) migration for one of our projects from the very beginning. During development we made some migrations. After some time, we found that, some of the migrations are related to setup/configuration. So we moved them up by renaming the migration files, like, from:
After then, we moved forward, and in some stage we made more migration files and then ran
php artisan migrate. But it came up with error:
Base table or view already exists: ... Table 'financial_years' already exists
So, we tried deleting the base table (in this case:
financial_years), and then deleted the row mentioning '...financial_years...' from the
migrations table too.
php artisan migrate came up with the same error again and again. We inspected the whole database, but found no
index or table of
Known remedy, but
We know that, we can run
php artisan migrate:refresh for a fresh migration. But the data we have in our database is important, we don't want to mess with the data right now. We might go for a fresh migration when to proceed to the production, but not now.
How can we proceed with the Laravel migration in this scenario?
The exception throws when you run migration command
php artisan migrate because migration actually wants the parent tables first, and then the child tables when there are relationships in between them.
In your case,
/migrations/directory rename your migration files so that the parent migration table timestamp appears before the child table's migration, and
- update the
migrationstable using the following command (before running that, find respective the row id and place it in
UPDATE `migrations` SET `migration`='2016_08_31_104213_create_financial_years_table' WHERE `id`= ?;
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS create a multi select Form field
- → October CMS - Conditionally Load a Different Page
- → How to disable assets combining on development in OctoberCMS
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → OctoberCms component: How to display all ID(items) instead of sorting only one ID?
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?