-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added unique constraints for entities #1073
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why constraint names differ across databases? This would complicate further migrations. Pls, use consistent naming. I would go for a pretty common prefix - uq_
Trying to embed the ohdsi schema (which is a dynamic/user defined value) into the constraint name is a little complicated, isn't it? Since we own the schema, we can ensure that the unique constraints are unique to the schema, right? If so, couldn't we just resort to simple naming conventsions like UQ_Table_Col type of formats, and not build dynamic sql in the migrations script? In addition, when we are troubleshooting problems people may have with these constrtaints, if we name them directly, we'll be able to offer assistance. If it's based on some application config, it becomes a barrier for us to tell them which constraints to check/disable. |
Agreed @chrisknoll - I'm updating the scripts to remove that from the constraint name as well as make some updates for the SQL Server migration script as I was having challenges running things against our SQL Server 2012 environment. |
@pavgra - some notes on my changes and from my side this is ready to merge in. The SQL Server migration script was problematic in our environment since chaining together the stored proc calls was not working well. I revised this script to use straight UPDATE statements to increment any duplicated names based on the row_number() to make them unique and then apply the constraints. The PostgreSQL script was also causing me challenges (I'm on v9) and so I revised that a bit to make sure the procedure call had the Per @chrisknoll's feedback I removed the |
Branches should be deleted after merge, please. |
@anthonysena, hi! there's a bug after your changes after completing this Line 3 in fc12285
we have the following state: ![]() so, rows with duplicate names (№1 and №2) appears and unique constraint can't be added. I managed this case in my previous procedures ( |
Thanks @aklochkova - you are absolutely right. Sorry to have missed that. Let me open an issue so that we can fix this migration script. |
Fixes OHDSI/Atlas#1338