From what I’ve seen before, it seems this error occurs due to a combination of a unique constraint application and the renaming/recreating of associations.
To solve this, you can upgrade to 8.18.11 (or higher), where the issue is solved. From those release notes:
If upgrading is not an option, there is also a workaround:
Runtime
and deploy the app.Database
and deploy the app again.
To toggle the setting you can go to Project settings -> Runtime -> Uniqueness validation
What this toggling does is that it first removes all the constraints and then re-adds them correctly. Please make sure to deploy the app each time with a newly built .mda.
I understand the original problem may be solved, this is more for future reference.
It seems you have been able to corrupt your local database. If you have a backup somewhere you could try to restore to that one. See documentation here: https://docs.mendix.com/developerportal/operate/restore-backup-locally
Otherwise you probably need to delete your local database (just cut and paste your deployment folder to somewhere else so at least you still have a backup of this and try to start the model again fresh. But you will have lost all your data with that action. A new local database will be created again.
Regards,
Ronald