migration-tool
migration-tool copied to clipboard
Using directus_users in a Many-to-One fails to migrate
Directus Legacy 8.8.1 Directus Node 9.6.0 Migration Tool - current
I have a table in v8 that references users as a many-to-one relationship from directus_users (a project that has a project leader). The mysql database field is an int as the v8 directus_user id field is an int. When the collection is migrated, the /relations migration breaks as the new relationship is incompatible.
V9 debug log:
00:35:22 🚨 alter table `project` add constraint `project_leader_foreign` foreign key (`leader`) references `directus_users` (`id`) - UNKNOWN_CODE_PLEASE_REPORT: Referencing column 'leader' and referenced column 'id' in foreign key constraint 'project_leader_foreign' are incompatible. Error: UNKNOWN_CODE_PLEASE_REPORT: Referencing column 'leader' and referenced column 'id' in foreign key constraint 'project_leader_foreign' are incompatible.
I think this is because the v9 directus_users' id field is now a char(32).
Any thoughts on how I can resolve this (as I've got a bunch of these relationships).
I've been having a similar issue to this. I don't get an error in the logs as the data ports over seemingly correctly.
However, the field when editing / creating a field gives an error saying the relationship wasn't configured correctly:
Additionally, trying to modify the field settings in the data model doesn't have an option to modify the relationship.
EDIT: Turns out the issue was due to the migration process not including directus_relations entries for each of the many to one user fields. Additionally, it hadn't added the additional configuration for these fields into the directus_fields table. Adding this data manually (using a manually created user_created field as a template) into the database seems to work.
@aSeriousDeveloper I may well have that issue to come if i can get relations with Users migrated! I'm surprised no one else has had this issue tbh.
@rijkvanzanten - any thoughts on this "UNKNOWN_CODE_PLEASE_REPORT" error message?