/*
 * V8_1_To_V8_2.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.Delete;

/**
 *
 * @author fpalma
 */
public class V8_1_To_V8_2
		implements siprp.update.Update
{
	
	/**
	 * Creates a new instance of V8_1_To_V8_2
	 */
	public V8_1_To_V8_2()
	{
	}
	
	public String []listChanges()
	{
		return new String[]{ "Alterar tabela dos ecds", "Alterar tabela de marca\u00e7\u00e3o dos ecds" };
	}
	
	public double getStartVersion()
	{
		return 8.1;
	}
	
	public double getEndVersion()
	{
		return 8.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( 
				"ALTER TABLE trabalhadores_ecd ADD enviado CHAR(1);" );
		executer.executeQuery( update );
		update = 
			new com.evolute.utils.sql.Update( 
				"ALTER TABLE trabalhadores_ecds_datas ADD analisador_id INT REFERENCES prestadores( id );" );
		executer.executeQuery( update );
		update = 
			new com.evolute.utils.sql.Update( 
				"ALTER TABLE trabalhadores_ecds_datas ADD data_envio DATE;" );
		executer.executeQuery( update );
		update = 
			new com.evolute.utils.sql.Update( 
				"ALTER TABLE trabalhadores_ecds_datas ADD data_recepcao DATE;" );
		executer.executeQuery( update );
		Delete delete = new Delete( "trabalhadores_ecd", null );
		executer.executeQuery( delete );
		delete = new Delete( "trabalhadores_ecds_datas_emails", null );
		executer.executeQuery( delete );
		delete = new Delete( "trabalhadores_ecds_datas_observacoes", null );
		executer.executeQuery( delete );
		delete = new Delete( "trabalhadores_ecds_datas", null );
		executer.executeQuery( delete );
		delete = new Delete( "trabalhadores_ecds", null );
		executer.executeQuery( delete );
		delete = new Delete( "trabalhadores_consultas_datas_emails", null );
		executer.executeQuery( delete );
		delete = new Delete( "trabalhadores_consultas_datas_observacoes", null );
		executer.executeQuery( delete );
		delete = new Delete( "trabalhadores_consultas_datas", null );
		executer.executeQuery( delete );
		delete = new Delete( "trabalhadores_consultas", null );
		executer.executeQuery( delete );
		delete = new Delete( "trabalhadores_fichas_aptidao", null );
		executer.executeQuery( delete );
		delete = new Delete( "trabalhadores_processo", null );
		executer.executeQuery( delete );
	}
	
	public String toString()
	{
		return "v" + getStartVersion() + " para v" + getEndVersion();
	}
}
