Hi Soham, When doing an upgrade/downgrade that involves the LOOKUP_VALUE and LOOKUP_VALUE_LOCALE tables, it needs to be done as a java based upgrade rather than a SQL upgrade. The reason for this is that a user can dynamically create data which will add lookup values. In this case an upgrade with a hard coded lookup value will overwrite user data. The tests are set up to fail in order to prevent this kind of overwrite error from occurring.
What you will need to do is create a java upgrade. If you look at DatabaseVersionPersistance you will find a number of methods like "register101". What you will need to do is create a new java upgrade class to handle interest types. You can use the class AddAccountStateFlag as a model. The end result of this is that you will have an upgrade which does not include any SQL files, but instead executes java methods to generate ID values at upgrade time. Cheers, --Van > Hi all, > I need to add some values (for interest type calculation) to the > database for a feature I am working on. I created the corresponging > updagrade and downgrade scripts, added the changes to the > latestdata.sql and tried to run the tests. The test fails saying that > the lookup value already exists. > > I think it might be because either the latest data is populating the > row, and the upgrade script is complaining or the other way round. > How do we typically go about doing this? > > I have attached the upgrade script and the latest data. (I also > updated the application version to 172 in > DatabaseVersionPersistance.java > > Here is the error > > java.lang.Exception: Cannot upgrade to 172 at > org.mifos.framework.persistence.LatestTest.upAndBack(LatestTest.java:156 ) > at > org.mifos.framework.persistence.LatestTest.afterLookupValues(LatestTest. java >> 144) > Caused by: net.sourceforge.mayfly.MayflySqlException: primary key > LOOKUP_ID already has a value 603 at > net.sourceforge.mayfly.MayflyException.(MayflyException.java:47) > at net.sourceforge.mayfly.MayflyException.(MayflyException.java:41) > at > net.sourceforge.mayfly.datastore.constraint.NotNullOrUnique.check(NotNul lOrU > nique.java:54) > at > net.sourceforge.mayfly.datastore.constraint.Constraints.check(Constraint s.ja > va:67) > at > net.sourceforge.mayfly.datastore.TableData.addRow(TableData.java:79) > at > net.sourceforge.mayfly.datastore.TableData.addRow(TableData.java:54) > at net.sourceforge.mayfly.datastore.Schema.addRow(Schema.java:161) > at > net.sourceforge.mayfly.datastore.DataStore.addRow(DataStore.java:123) > at > net.sourceforge.mayfly.evaluation.command.Insert.insertOneRow(Insert.jav a:45 > ) > at > net.sourceforge.mayfly.evaluation.command.Insert.update(Insert.java:35) > at > net.sourceforge.mayfly.evaluation.command.Command.update(Command.java:32 ) > at net.sourceforge.mayfly.Database.executeUpdate(Database.java:119) > at > net.sourceforge.mayfly.MayflyConnection.executeUpdate(MayflyConnection.j ava: > 74) > at > net.sourceforge.mayfly.MayflyConnection.execute(MayflyConnection.java:63 ) > at > net.sourceforge.mayfly.jdbc.JdbcStatement.executeUpdate(JdbcStatement.ja va:3 > 2) > at > org.mifos.framework.persistence.SqlUpgrade.execute(SqlUpgrade.java:49) > at > org.mifos.framework.persistence.SqlUpgrade.upgrade(SqlUpgrade.java:32) > at > org.mifos.framework.persistence.LatestTest.upAndBack(LatestTest.java:172 ) > at > org.mifos.framework.persistence.LatestTest.upAndBack(LatestTest.java:153 ) > > > Please help. > > Thanks > Soham > > > ------------------------------------------------------------------------ - > This SF.net email is sponsored by: Microsoft Defy all challenges. > Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
