Hi Van, 2 more question, 1. Which package should the upgrade class belong to? I see that the new upgrades (167, 169) are in package org.mifos.application.master.persistence. Or should they go with their corresponding package like AddAccountStateFlag which is in package org.mifos.application.accounts.business;
2. Do I need to manually add the changes to latest-data.sql? Thanks Soham >-----Original Message----- >From: [EMAIL PROTECTED] >[mailto:[EMAIL PROTECTED] On >Behalf Of Van Mittal-Henkle >Sent: Friday, January 25, 2008 2:58 AM >To: Developer >Subject: Re: [Mifos-developer] Question related to database >upgrade scriptsandtesting > >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(La >testTest. >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.che >ck(NotNul >lOrU >> nique.java:54) >> at >> >net.sourceforge.mayfly.datastore.constraint.Constraints.check(C >onstraint >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(I >nsert.jav >a:45 >> ) >> at >> >net.sourceforge.mayfly.evaluation.command.Insert.update(Insert.java:35) >> at >> >net.sourceforge.mayfly.evaluation.command.Command.update(Comman >d.java:32 >) >> at net.sourceforge.mayfly.Database.executeUpdate(Database.java:119) >> at >> >net.sourceforge.mayfly.MayflyConnection.executeUpdate(MayflyCon >nection.j >ava: >> 74) >> at >> >net.sourceforge.mayfly.MayflyConnection.execute(MayflyConnectio >n.java:63 >) >> at >> >net.sourceforge.mayfly.jdbc.JdbcStatement.executeUpdate(JdbcSta >tement.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/ ------------------------------------------------------------------------- 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/
