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 ?
IF you want to re-migrate all the database, you can simply do: php artisan migrate:refresh . IF you want to make sure your database to be clean with your latest changes, you can drop your entire database tables and do php artisan migrate again. Also, you can try php artisan migrate --seed if you have any seeder.
To create a new migration, you can run the make:migration Artisan command and that will bootstrap a new class on your Laravel application, in the database/migrations folder. This class will contain a default boilerplate code.
Roll Back & Migrate Using A Single Command The migrate:refresh command will roll back all of your migrations and then execute the migrate command. This command effectively re-creates your entire database: php artisan migrate:refresh. # Refresh the database and run all database seeds... php artisan migrate:refresh -- ...
I've fixed issue by following steps:
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.
php artisan migrate
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With