Closed dgvirtual closed 1 year ago
I understand sqlite3 is not everyone's favourite db engine, but just in case anyone wants more data for debugging, – let me know.
I have just checked: after creating a user id=5 in db, running this insert statement in sql console is successfull:
INSERT INTO `auth_identities` (`user_id`, `type`, `secret`, `secret2`, `created_at`, `updated_at`) VALUES (5, 'email_password', 'vardas5@pavarde.lt', '$2y$10$kuRm8Cv/EZKMXAoxSKXWE.XyciS.LKOr987/0.qaX4G56piwG.HZu', '2022-10-12 12:11:24', '2022-10-12 12:11:24')
So I think I have found the offending issue in the database. I exported the whole database as an sql file and found this at the end, where indexes are created:
CREATE UNIQUE INDEX IF NOT EXISTS "auth_identities_type_secret" ON "auth_identities" ( "type", "secret" );
as indexes are created only on unique fields, the index on "type" does not make sense...
After removing this index from the DB the error no longer happens. However, for each user I save there are two identities created in auth_identities DB table. Why? Only the first entry to be created is later modified if I modify the user, the other one remains untouched.
I presume the indexes are automatically created by Codeigniter migrations on all unique fields. And I see code
$this->forge->addUniqueKey(['type', 'secret']);
in the Shield Migrations file. How can that be so? That code must have worked for a lot of users for years now?
Can no longer reproduce the issue.
I am using sqlite db and get this error when saving a new user. The user is actually saved fine...
Here is the full log entry for this error:
I am not sure what is causing this error. The screenshot says: "SQLite3::exec(): UNIQUE constraint failed: auth_identities.type, auth_identities.secret" - however, there is no unique constraint on those columns in the database, and while the type column content is not unique, the column "secret" has all unique values (the one that was inserted, despite this error message, was the last one, id = 4). Here is the relevant part of sql dump: