/*
 * V7_0_To_V7_2.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_0_To_V7_2 
		implements siprp.update.Update
{
	
	/**
	 * Creates a new instance of V7_0_To_V7_2
	 */
	public V7_0_To_V7_2()
	{
	}
	
	public String []listChanges()
	{
		return new String[]{ "Criar tabela dos processos" };
	}
	
	public double getStartVersion()
	{
		return 7.0;
	}
	
	public double getEndVersion()
	{
		return 7.2;
	}
	
	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 marcacoes_processo "
					+ "( "
					+ "id serial NOT NULL, "
					+ "trabalhador_id int4 NOT NULL, "
					+ "estado char(1) NOT NULL DEFAULT 'a'::bpchar, "
					+ "data_inicio date, "
					+ "data_fim date, "
					+ "CONSTRAINT marcacoes_processo_pkey PRIMARY KEY (id), "
					+ "CONSTRAINT marcacoes_processo_trabalhador_id_fkey FOREIGN KEY (trabalhador_id) "
					+ "REFERENCES trabalhadores (id) MATCH SIMPLE "
					+ "ON UPDATE NO ACTION ON DELETE NO ACTION "
					+ ") "
					+ "WITHOUT OIDS;" );
		executer.executeQuery( update );
	}
	
	public String toString()
	{
		return "v7.0 para v7.2";
	}
}
