Skip to content
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

Disciplines cannot be deleted due to Specify 7's uniquenessrule table #1243

Open
grantfitzsimmons opened this issue Jul 11, 2024 · 1 comment

Comments

@grantfitzsimmons
Copy link
Member

Attempting to delete a discipline in Specify 6 fails due to the following error:

com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot delete or update a parent row: a foreign key constraint fails (`oakspring`.`uniquenessrule`, CONSTRAINT `uniquenessrule_DisciplineID_09ca1c68_fk_disciplin` FOREIGN KEY (`DisciplineID`) REFERENCES `discipline` (`UserGroupScopeId`))
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	at com.mysql.jdbc.Util.handleNewInstance(Util.java:389)
	at com.mysql.jdbc.Util.getInstance(Util.java:372)
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:973)
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3835)
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3771)
	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2435)
	at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2582)
	at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2531)
	at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1618)
	at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1549)
	at edu.ku.brc.specify.dbsupport.SpecifyDeleteHelper.deleteDiscipline(SpecifyDeleteHelper.java:1206)
	at edu.ku.brc.specify.dbsupport.SpecifyDeleteHelper.deleteRecords(SpecifyDeleteHelper.java:1101)
	at edu.ku.brc.specify.dbsupport.SpecifyDeleteHelper.delRecordFromTable(SpecifyDeleteHelper.java:510)
	at edu.ku.brc.specify.dbsupport.SpecifyDeleteHelper.delRecordFromTable(SpecifyDeleteHelper.java:452)
	at edu.ku.brc.specify.datamodel.busrules.DisciplineBusRules$6.doInBackground(DisciplineBusRules.java:548)
	at edu.ku.brc.specify.datamodel.busrules.DisciplineBusRules$6.doInBackground(DisciplineBusRules.java:539)
	at javax.swing.SwingWorker$1.call(SwingWorker.java:295)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at javax.swing.SwingWorker.run(SwingWorker.java:334)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)

Presumably the migration creates new records that Specify 6 is not aware of. This means that there is not currently a way to remove a discipline from within Specify itself if Specify 7 is used alongside Specify 6.

@realVinayak
Copy link

hmm setting the constraint to cascade instead of protect will fix this.. (on uniquenessrule table). I guess that we should have done it that way, anyways. We can still do this, via a migration..

I drop the constraint on uniquenessrule, and add a new one with cascade for it, when I need to delete disciplines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants