diff --git a/trunk/SIPRPSoft/src/siprp/update/UpdateList.java b/trunk/SIPRPSoft/src/siprp/update/UpdateList.java index 654680e8..f388a07d 100644 --- a/trunk/SIPRPSoft/src/siprp/update/UpdateList.java +++ b/trunk/SIPRPSoft/src/siprp/update/UpdateList.java @@ -27,7 +27,7 @@ public class UpdateList new Update[]{ new siprp.update.updates.V6_1_To_V7_0(), new siprp.update.updates.V7_0_To_V7_2(), new siprp.update.updates.V7_2_To_V7_4(), new siprp.update.updates.V7_4_To_V7_5(), new siprp.update.updates.V7_5_To_V7_6(), new siprp.update.updates.V7_6_To_V7_7(), - new siprp.update.updates.V7_7_To_V7_8() }; + new siprp.update.updates.V7_7_To_V7_8(), new siprp.update.updates.V7_8_To_V7_9() }; protected static Executer EXECUTER; protected static double version = -1; diff --git a/trunk/SIPRPSoft/src/siprp/update/updates/V7_8_To_V7_9.java b/trunk/SIPRPSoft/src/siprp/update/updates/V7_8_To_V7_9.java new file mode 100644 index 00000000..f5946acf --- /dev/null +++ b/trunk/SIPRPSoft/src/siprp/update/updates/V7_8_To_V7_9.java @@ -0,0 +1,83 @@ +/* + * V7_8_To_V7_9.java + * + * Created on December 19, 2007, 3:12 PM + * + * To change this template, choose Tools | Template Manager + * and open the template in the editor. + */ + +package siprp.update.updates; + +import com.evolute.utils.Singleton; +import com.evolute.utils.db.DBManager; +import com.evolute.utils.db.Executer; +import com.evolute.utils.sql.Assignment; +import com.evolute.utils.sql.Field; + +/** + * + * @author fpalma + */ +public class V7_8_To_V7_9 + implements siprp.update.Update +{ + + /** + * Creates a new instance of V7_8_To_V7_9 + */ + public V7_8_To_V7_9() + { + } + + public String []listChanges() + { + return new String[]{ "Alterar tabela dos estabelecimentos para ter prestadores por defeito"}; + } + + public double getStartVersion() + { + return 7.8; + } + + public double getEndVersion() + { + return 7.9; + } + + public void doUpdate() + throws Exception + { + DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER ); + Executer executer = dbm.getSharedExecuter(); + com.evolute.utils.sql.Update update = + new com.evolute.utils.sql.Update( + "ALTER TABLE estabelecimentos ADD prestador_consulta_id INTEGER REFERENCES prestadores( id );" ); + executer.executeQuery( update ); + update = + new com.evolute.utils.sql.Update( + "ALTER TABLE estabelecimentos ADD prestador_ecds_id INTEGER REFERENCES prestadores( id );" ); + executer.executeQuery( update ); + update = + new com.evolute.utils.sql.Update( + "ALTER TABLE estabelecimentos ADD aux INT REFERENCES contactos(id);" ); + executer.executeQuery( update ); + update = + new com.evolute.utils.sql.Update( + "UPDATE estabelecimentos SET aux = CAST( contacto AS INTEGER);" ); + executer.executeQuery( update ); + update = + new com.evolute.utils.sql.Update( + "ALTER TABLE estabelecimentos RENAME contacto TO contacto_backup;" ); + executer.executeQuery( update ); + update = + new com.evolute.utils.sql.Update( + "ALTER TABLE estabelecimentos RENAME aux TO contacto_id;" ); + executer.executeQuery( update ); + } + + public String toString() + { + return "v" + getStartVersion() + " para v" + getEndVersion(); + } +}