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

Foreign Key on Setup

Post by jim1506 » 02 Sep 2019, 16:40

I have the following error when installing and I get to installing the demo data. I have made the amendments to config/database.php. It is Larvel 5.8 on Linux.

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: 7885
Joined: 01 Jan 1970, 00:00

Re: Foreign Key on Setup

Post by aimeos » 02 Sep 2019, 17:23

What's the charset and collation of your "users" table? What are the table options in your ./config/database.php file?
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, 05:12

I copied the changes from your instructions:

'mysql' => [
'driver' => 'mysql',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'prefix_indexes' => true,
'strict' => true,
'engine' => null,
'options' => extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
]) : [],
],

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

Re: Foreign Key on Setup

Post by aimeos » 03 Sep 2019, 06:30

Can you please post the output of

Code: Select all

SHOW CREATE TABLE `users`
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, 07:44

from Navicat's table information:


CREATE TABLE `users` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`email` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`email_verified_at` timestamp NULL DEFAULT NULL,
`password` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`remember_token` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
`superuser` smallint(6) NOT NULL DEFAULT 0,
`siteid` int(11) DEFAULT NULL,
`label` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`salutation` varchar(8) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`company` varchar(100) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`vatid` varchar(32) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`title` varchar(64) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`firstname` varchar(64) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`lastname` varchar(64) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`address1` varchar(200) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`address2` varchar(200) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`address3` varchar(200) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`postal` varchar(16) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`city` varchar(200) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`state` varchar(200) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`langid` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
`countryid` char(2) COLLATE utf8_unicode_ci DEFAULT NULL,
`telephone` varchar(32) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`telefax` varchar(32) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`website` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`longitude` decimal(8,6) DEFAULT NULL,
`latitude` decimal(8,6) DEFAULT NULL,
`birthday` date DEFAULT NULL,
`vdate` date DEFAULT NULL,
`status` smallint(6) NOT NULL DEFAULT 1,
`editor` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
UNIQUE KEY `users_email_unique` (`email`),
KEY `idx_lvusr_langid` (`langid`),
KEY `idx_lvusr_last_first` (`lastname`,`firstname`),
KEY `idx_lvusr_post_addr1` (`postal`,`address1`),
KEY `idx_lvusr_post_city` (`postal`,`city`),
KEY `idx_lvusr_lastname` (`lastname`),
KEY `idx_lvusr_address1` (`address1`),
KEY `idx_lvusr_city` (`city`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

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

Re: Foreign Key on Setup

Post by aimeos » 03 Sep 2019, 08:33

Which Aimeos version do you use?
Please make sure the columns "users.id" and "users_address.parentid", "users_list.parentid" "users_property.parentid" are using the same column definition. The easiest was would be to remove the "unsigned" from the users.id column.
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, 09:02

I removed the unsiqned from the users.id and the users_address.parentid was unsigned. The tables users_list.parentid and users_property.parentid are not there. I tried to rerun the setup command but got the same error.

I downloaded from composer yesterday. Composer is showing "aimeos/aimeos-laravel": "~2018.07"

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

Re: Foreign Key on Setup

Post by aimeos » 03 Sep 2019, 09:10

You should use the latest version which is 2019.07.
All referenced columns need the same attributes so if users_address.parentid is unsigend, users.id have to be unsigend too.

What version of MySQL (or a derivate) are you using?
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, 09:39

I manually changed the version in composer.json (but this was only installed yesterday via composer so you may wish to look at this) and ran an update. It updated to the later version.

I tried php artisan aimeos:setup --option=setup/default/demo:1 but got the same error.

My version of mySQL is MariaDB

10.2.26-MariaDB-log-cll-lve - MariaDB Server

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

Re: Foreign Key on Setup

Post by aimeos » 03 Sep 2019, 09:45

Can you please drop your database and rerun again so we have a clean state?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply