gnikyt / laravel-shopify

A full-featured Laravel package for aiding in Shopify App development
MIT License
1.24k stars 374 forks source link

Migration error #1148

Closed CHEWX closed 2 years ago

CHEWX commented 2 years ago

For bug reporting only! If you're posting a feature request or discussion, please ignore.

Expected Behavior

Running php artisan migrate to successfully run.

Current Behavior

Hitting an error, only with this package required, I removed and test and it successfully worked.

Failure Information

Please help provide information about the failure if this is a bug.

Migrating: 2020_01_29_231006_create_charges_table

   Illuminate\Database\QueryException

  SQLSTATE[42S01]: Base table or view already exists: 1050 Unknown error 1050 (SQL: create table `charges` (`id` int unsigned not null auto_increment primary key, `charge_id` bigint not null, `test` tinyint(1) not null default '0', `status` varchar(255) null, `name` varchar(255) null, `terms` varchar(255) null, `type` varchar(255) not null, `price` decimal(8, 2) not null, `capped_amount` decimal(8, 2) null, `trial_days` int null, `billing_on` timestamp null, `activated_on` timestamp null, `trial_ends_on` timestamp null, `cancelled_on` timestamp null, `expires_on` timestamp null, `plan_id` int unsigned null, `description` varchar(255) null, `reference_charge` bigint null, `created_at` timestamp null, `updated_at` timestamp null, `deleted_at` timestamp null, `user_id` bigint unsigned not null) default character set utf8mb4 collate 'utf8mb4_unicode_ci')

Steps to Reproduce

Please provide detailed steps for reproducing the issue.

  1. composer require osiset/laravel-shopify
  2. php artisan migrate
CHEWX commented 2 years ago

If I delete the charges table and re-run.

Migrating: 2020_01_29_231006_create_charges_table

   Illuminate\Database\QueryException

  SQLSTATE[HY000]: General error: 1215 Unknown error 1215 (SQL: alter table `charges` add constraint `charges_user_id_foreign` foreign key (`user_id`) references `users` (`id`) on delete cascade)
Kyon147 commented 2 years ago

Have you set up your database and are you using mysql?

Deleting the table and trying to rerun will cause the error, as there will be a foreign key on users already from the migration and will try to add it again.

I would rollback and start again, rather than delete directly as you will break the migration intended purpose.

Kyon147 commented 2 years ago

Closing as the ticket is stale. Re-open if issue persists.