aimeos / aimeos-laravel

Laravel ecommerce package for ultra fast online shops, scalable marketplaces, complex B2B applications and #gigacommerce
https://aimeos.org/Laravel
MIT License
7.26k stars 1.05k forks source link

SQLSTATE[HY000]: General error: 1833 Cannot change column 'id': used in a foreign key constraint #115

Closed symfonycoda closed 7 years ago

symfonycoda commented 7 years ago

Hi

I have built a small project in Laravel 5.3, and want to add Aimeos to it. I have followed the documentation, but when I get to the command "php artisan aimeos:setup --option=setup/default/demo:1", I get an error message. Everything seems successful until checking the users table:

`Using schema from customer.php Checking table "mshop_customer": done Checking table "mshop_customer_address": done Checking table "mshop_customer_list_type": done Checking table "mshop_customer_list": done Checking table "mshop_customer_group": done Checking table "users":

[Aimeos\MW\DB\Exception] Executing statement "ALTER TABLE users CHANGE id id INT AUTO_INCREMENT NOT NULL, CHANGE created_at created_at DATETIME NOT NULL, CHANGE updated_at updated_at DATETIME N OT NULL, CHANGE salutation salutation VARCHAR(8) NOT NULL, CHANGE company company VARCHAR(100) NOT NULL, CHANGE vatid vatid VARCHAR(32) NOT NULL, CHANGE title title VAR CHAR(64) NOT NULL, CHANGE firstname firstname VARCHAR(64) NOT NULL, CHANGE lastname lastname VARCHAR(64) NOT NULL, CHANGE address1 address1 VARCHAR(255) NOT NULL, CHANG E address2 address2 VARCHAR(255) NOT NULL, CHANGE address3 address3 VARCHAR(255) NOT NULL, CHANGE postal postal VARCHAR(16) NOT NULL, CHANGE city city VARCHAR(255) NOT NULL, CHANGE state state VARCHAR(255) NOT NULL, CHANGE telephone telephone VARCHAR(32) NOT NULL, CHANGE telefax telefax VARCHAR(32) NOT NULL, CHANGE website website VAR CHAR(255) NOT NULL, CHANGE status status SMALLINT NOT NULL, CHANGE editor editor VARCHAR(255) NOT NULL, CHANGE label label VARCHAR(255) NOT NULL" failed: An exception o ccurred while executing 'ALTER TABLE users CHANGE id id INT AUTO_INCREMENT NOT NULL, CHANGE created_at created_at DATETIME NOT NULL, CHANGE updated_at updated_at DATETI ME NOT NULL, CHANGE salutation salutation VARCHAR(8) NOT NULL, CHANGE company company VARCHAR(100) NOT NULL, CHANGE vatid vatid VARCHAR(32) NOT NULL, CHANGE title title VARCHAR(64) NOT NULL, CHANGE firstname firstname VARCHAR(64) NOT NULL, CHANGE lastname lastname VARCHAR(64) NOT NULL, CHANGE address1 address1 VARCHAR(255) NOT NULL, C HANGE address2 address2 VARCHAR(255) NOT NULL, CHANGE address3 address3 VARCHAR(255) NOT NULL, CHANGE postal postal VARCHAR(16) NOT NULL, CHANGE city city VARCHAR(255) NOT NULL, CHANGE state state VARCHAR(255) NOT NULL, CHANGE telephone telephone VARCHAR(32) NOT NULL, CHANGE telefax telefax VARCHAR(32) NOT NULL, CHANGE website website VARCHAR(255) NOT NULL, CHANGE status status SMALLINT NOT NULL, CHANGE editor editor VARCHAR(255) NOT NULL, CHANGE label label VARCHAR(255) NOT NULL': SQLSTATE[HY000]: General error: 1833 Cannot change column 'id': used in a foreign key constraint 'posts_author_id_foreign' of table 'notdrupal_db.posts'`

so it seems like the foreign key constraint for my 'posts' table will not allow Aimeos to continue. What are my options to fix this please?

If I find a solution I will let you know

Thanks in advance

aimeos commented 7 years ago

You can remove that foreign key constraint temporarily, run aimeos:setup and re-add the constraint afterwards. The next time you run aimeos:setup, nothing should be changed any more so the error shouldn't occur again.

For a more detailed analysis, you must post the output of show create table ... for the users table and your posts table.

symfonycoda commented 7 years ago

Hey. thats great.

It worked. All installed now

femi89 commented 4 years ago

You really saved my time