Getting error while run migrate command in laravel 8
Asked Answered
A

1

6

I'm using Laravel Cashier package.

I've added below line AppServiceProvider.php > boot method

 Cashier::ignoreMigrations();

I've create my own migration i.e: create_subscriptions_table and create_subscription_items_table

When I run php artisan migrate command then getting below error:

   Migrating: 2019_05_03_000002_create_subscriptions_table

   Illuminate\Database\QueryException 

  SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'subscriptions' already exists (SQL: create table `subscriptions` (`id` bigint unsigned not null auto_increment primary key, `user_id` bigint unsigned not null, `name` varchar(191) not null, `stripe_id` varchar(191) not null, `stripe_status` varchar(191) not null, `stripe_plan` varchar(191) null, `quantity` int null, `trial_ends_at` timestamp null, `ends_at` timestamp null, `created_at` timestamp null, `updated_at` timestamp null) default character set utf8mb4 collate 'utf8mb4_unicode_ci') 

I get this error because migration 2019_05_03_000002_create_subscriptions_table is in vendor folder.

I want run my own migration not from vendor so is there any solution to fix this issue ?

Arsis answered 11/6, 2021 at 9:10 Comment(2)
After you add Cashier::ignoreMigrations(); in AppServiceProvider, you dropped all tabled and re-run migration? Or just run php artisan migrate?Bemused
I've run php artisan migrate commandArsis
A
4

I've fixed issue by following steps:

  1. First I run command php artisan vendor:publish --tag="cashier-migrations". It will create a new migrations and I've removed code of up() and down() method from new migrations.

By doing this we can keep our override migration of Cashier package.

  1. Run command php artisan migrate
Arsis answered 12/6, 2021 at 5:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.