/*
 * V7_4_To_V7_5.java
 *
 * Created on 26 de Setembro de 2006, 11:48
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package siprp.update.updates;

import com.evolute.utils.*;
import com.evolute.utils.arrays.*;
import com.evolute.utils.db.*;
import com.evolute.utils.sql.*;


/**
 *
 * @author fpalma
 */
public class V7_4_To_V7_5 
		implements siprp.update.Update
{
	
	/**
	 * Creates a new instance of V7_4_To_V7_5
	 */
	public V7_4_To_V7_5()
	{
	}
	
	public String []listChanges()
	{
		return new String[]{ "Ligar processo a ficha de aptid\u00e3o" };
	}
	
	public double getStartVersion()
	{
		return 7.4;
	}
	
	public double getEndVersion()
	{
		return 7.5;
	}
	
	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( 
					"CREATE TABLE trabalhadores_fichas_aptidao"
					+"("
					+"  id serial,"
					+"  processo_id int4,"
					+"  exame_id int4,"
					+"  CONSTRAINT trabalhadores_fichas_aptidao_pkey PRIMARY KEY (id),"
					+"  CONSTRAINT trabalhadores_fichas_aptidao_exame_id_fkey FOREIGN KEY (exame_id) REFERENCES exames (id) ON UPDATE RESTRICT ON DELETE RESTRICT,"
					+"  CONSTRAINT trabalhadores_fichas_aptidao_processo_id_fkey FOREIGN KEY (processo_id) REFERENCES trabalhadores_processo (id) ON UPDATE RESTRICT ON DELETE RESTRICT"
					+")" 
					+"WITHOUT OIDS;"
					+"ALTER TABLE trabalhadores_fichas_aptidao OWNER TO postgres;" );
		executer.executeQuery( update );
	}
	
	public String toString()
	{
		return "v7.4 para v7.5";
	}
}
