forked from Coded/SIPRP
				
			git-svn-id: https://svn.coded.pt/svn/SIPRP@614 bb69d46d-e84e-40c8-a05a-06db0d633741
	
		
	
				
					
				
			
							parent
							
								
									b244b5210e
								
							
						
					
					
						commit
						9b03f62a00
					
				| @ -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(); | ||||||
|  | 	} | ||||||
|  | } | ||||||
					Loading…
					
					
				
		Reference in new issue