Foreign Key on Setup

Help for integrating the Laravel package
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
jim1506
Posts: 10
Joined: 05 Aug 2018, 20:57

Re: Foreign Key on Setup

Post by jim1506 » 03 Sep 2019, 10:02

Ok. I dropped all the tables and re-ran php artisan migrate.

I then ran

php artisan aimeos:setup --option=setup/default/demo:1

and got the error message

Aimeos\MW\DB\Exception : SQLSTATE[HY000]: General error: 1005 Can't create table `tdbhosti_demoshop`.`users_address` (errno: 150 "Foreign key constraint is incorrectly formed")

jim1506
Posts: 10
Joined: 05 Aug 2018, 20:57

Re: Foreign Key on Setup

Post by jim1506 » 03 Sep 2019, 10:03

sorry I should have mentioned I changed the structure of user so id was unsigned

jim1506
Posts: 10
Joined: 05 Aug 2018, 20:57

Re: Foreign Key on Setup

Post by jim1506 » 03 Sep 2019, 12:00

I have done that - redone the migration - changed the unsigned on users.

When I run

php artisan aimeos:setup --option=setup/default/demo:1

I get

Aimeos\MW\DB\Exception : SQLSTATE[HY000]: General error: 1005 Can't create table `tdbhosti_demoshop`.`users_address` (errno: 150 "Foreign key constraint is incorrectly formed")

User avatar
aimeos
Administrator
Posts: 7881
Joined: 01 Jan 1970, 00:00

Re: Foreign Key on Setup

Post by aimeos » 03 Sep 2019, 12:12

Please make sure the users.id and user_address.parentid columns are of the same type and length:
https://stackoverflow.com/questions/843 ... rmed-error
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

jim1506
Posts: 10
Joined: 05 Aug 2018, 20:57

Re: Foreign Key on Setup

Post by jim1506 » 03 Sep 2019, 13:48

They are:

users:
id` int(10) unsigned NOT NULL AUTO_INCREMENT,

users_address
`parentid` int(10) unsigned NOT NULL,

The only difference is auto increment

User avatar
aimeos
Administrator
Posts: 7881
Joined: 01 Jan 1970, 00:00

Re: Foreign Key on Setup

Post by aimeos » 04 Sep 2019, 07:23

You can try

Code: Select all

SHOW ENGINE INNODB STATUS
to show the last InnoDB foreign key error. This can maybe yield more information about the problem:
https://mariadb.com/kb/en/library/show- ... db-status/
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

jim1506
Posts: 10
Joined: 05 Aug 2018, 20:57

Re: Foreign Key on Setup

Post by jim1506 » 04 Sep 2019, 08:57

Same reply as the laravel error

nhakhtn
Posts: 1
Joined: 16 Jul 2022, 02:50

Re: Foreign Key on Setup

Post by nhakhtn » 16 Jul 2022, 02:51

you should go to table `users` then change the type of table from MyISAM to InnoDB, then it will be solved!

Post Reply