-
Notifications
You must be signed in to change notification settings - Fork 36
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
Make default catalogNumber uniqueness rule editable #5400
base: production
Are you sure you want to change the base?
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.
Testing instructions
- Go the SchemaConfig page for the CollectionObject table
- Ensure the "CatalogNumber must be unique to Collection" Uniqueness Rule which used to be readonly is now editable
- Modify or delete the Uniqueness Rule
- Save a CollectionObject with a duplicate catalognumber in the collection
Working as expected 👍👍👍
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.
Testing instructions
- Go the SchemaConfig page for the CollectionObject table
- Ensure the "CatalogNumber must be unique to Collection" Uniqueness Rule which used to be readonly is now editable
- Modify or delete the Uniqueness Rule
- Save a CollectionObject with a duplicate catalognumber in the collection
Looks good, can modify and delete and add the rule back as long as there aren't any duplicates!
SELECT stat.INDEX_NAME | ||
FROM information_schema.statistics stat | ||
WHERE stat.TABLE_SCHEMA = %s | ||
AND stat.TABLE_NAME = 'collectionobject' |
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.
You took the complicated route! I hope there aren't many instances where it differs from our current database schema, but at least it's managed. Nice work!
@specify/dev-testing Someone needs to test this in MySQL 5.7. Does anyone have it installed? |
I tested this using the MySQL 5.7 docker image and so no difference from MariaDB. If anyone else wishes to test this, here is the service I used in the mysql:
platform: linux/x86_64
image: mysql:5.7
restart: unless-stopped
environment:
MYSQL_DATABASE: "specify"
MYSQL_USER: "master"
MYSQL_PASSWORD: "master"
MYSQL_ROOT_PASSWORD: "root"
ports:
- "127.0.0.1:3006:3306"
expose:
- "3306"
volumes:
- "database:/var/lib/mysql" I am using an M1 macOS, and the image is not supported on the architecture. I have the container running on |
@specify/dev-testing There is one question which probably needs answering and bears discussion (or at least can be noted) before this is merged. Let's say that a user has applied these two migrations and has created CollectionObjects with duplicate catalog numbers. If they were to reverse the I think there are three approaches we can take:
|
Fixes #5229
Checklist
and self-explanatory (or properly documented)
Testing instructions
For Developers (and/or the technically inclined with local instances)
This should be tested in both MySQL and MariaDB
After running/reversing the
0003_catnum_constraint
migration, check the indices/constrains at the database levelSHOW INDEXES FROM collectionobject;
,SHOW CREATE TABLE collectionobject;
, or a more specific query like:SELECT * FROM information_schema.statistics WHERE table_schema=(SELECT DATABASE()) AND table_name='collectionobject' AND non_unique=0;
After running the
0003_catnum_constraint
migration, open Specify 6 and ensure that the basic functionality ofThe reverse side of the
0004_catnum_uniquerule
migration should handle the case where the Uniqueness Rule doesn't exist (i.e., deleted) or has been modified and recreate it.