/*
 * V7_7_To_V7_8.java
 *
 * Created on May 15, 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 lflores
 */
public class V7_7_To_V7_8
		implements siprp.update.Update
{
	
	/**
	 * Creates a new instance of V7_7_To_V7_8
	 */
	public V7_7_To_V7_8()
	{
	}
	
	public String []listChanges()
	{
		return new String[]{ "Alterar tabela das datas de exames para incluir o prestador",
								"Alterar tabela das datas de consulta para incluir o prestador"};
	}
	
	public double getStartVersion()
	{
		return 7.7;
	}
	
	public double getEndVersion()
	{
		return 7.8;
	}
	
	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_ecds_datas ADD prestador_id INTEGER REFERENCES prestadores( id );" );
		executer.executeQuery( update );
		update = new com.evolute.utils.sql.Update( 
					"ALTER TABLE trabalhadores_consultas_datas ADD prestador_id INTEGER REFERENCES prestadores( id );" );
		executer.executeQuery( update );
		
	}
	
	public String toString()
	{
		return "v" + getStartVersion() + " para v" + getEndVersion();
	}
}
