It looks like you have a pre-existing foreign key with the contacts table that you will need to drop also.
Filament User setup error: Id field
I changed the id field in the users table to use ulids...
Schema::create('users', function (Blueprint $table) {
$table->ulid('id')->primary();
however, when I try to assign user_id as a foreign key on another table, I get the following error:
SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`eomd`.`contacts`, CONSTRAINT `contacts_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE)
Upon checking the query, I noticed the user_id field is getting an integer value of 1 and I'm not sure where that came from.
insert into `contacts` (`first_name`, `last_name`, `other_names`, `country_id`, `state_id`, `address_line_1`, `address_line_2`, `city`, `postal_code`, `require_email_verification`, `require_phone_verification`, `require_id_verification`, `require_security_question_verification`, `id`, `user_id`, `updated_at`, `created_at`) values (John, Doe ?, 83, 54, GS-0299-3293, ?, Ohio, 00111, 0, 0, 0, 0, 01HGE14CXHQGZDYAN14B3MR76N, 1, 2023-11-29 17:13:24, 2023-11-29 17:13:24)
I tried to log in as another user and it keeps logging back in as this same user with an ID of 1. Is there some extra configuration I need to do for the user setup?
Changing the primary key of the model is perhaps the culprit, @lyndon. Have you the following in your User model?
public $incrementing = false;
...this tells your model that the primary key isn't going to auto increment. As it's trying to get 1, I can assume that's what it believes is the first in the auto incrementing primary key.
Please or to participate in this conversation.