forked from Coded/SIPRP
git-svn-id: https://svn.coded.pt/svn/SIPRP@1256 bb69d46d-e84e-40c8-a05a-06db0d633741
parent
89a1455ae6
commit
72fe94026b
@ -0,0 +1,45 @@
|
||||
package siprp.update.updates;
|
||||
|
||||
import com.evolute.module.updater.AbstractUpdate;
|
||||
import com.evolute.utils.db.PSQLSequenceUtils;
|
||||
import com.evolute.utils.sql.Update;
|
||||
|
||||
public class V12_2_To_V12_3 extends AbstractUpdate
|
||||
{
|
||||
|
||||
public V12_2_To_V12_3()
|
||||
{
|
||||
super( 12.2, 12.3, "A corrigir chaves primarias" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doUpdate() throws Exception
|
||||
{
|
||||
fixIdColumn( "avisos", "id" );
|
||||
fixIdColumn( "contactos", "id" );
|
||||
fixIdColumn( "empresas", "id" );
|
||||
fixIdColumn( "estabelecimentos", "id" );
|
||||
fixIdColumn( "exames", "id" );
|
||||
fixIdColumn( "exames_perfis", "id" );
|
||||
fixIdColumn( "historico_estabelecimento", "id" );
|
||||
fixIdColumn( "marcacoes_empresa", "id" );
|
||||
fixIdColumn( "marcacoes_estabelecimento", "id" );
|
||||
fixIdColumn( "marcacoes_tecnicos_hst", "id" );
|
||||
fixIdColumn( "marcacoes_trabalhador", "id" );
|
||||
fixIdColumn( "medicos", "id" );
|
||||
fixIdColumn( "prt_grupos_protocolo", "id" );
|
||||
fixIdColumn( "prt_tipos_elementos_protocolo", "id" );
|
||||
fixIdColumn( "tipos_exames_comp", "id" );
|
||||
fixIdColumn( "trabalhadores", "id" );
|
||||
}
|
||||
|
||||
private void fixIdColumn( String columnName, String idField ) throws Exception
|
||||
{
|
||||
executeQuery( new Update(
|
||||
"create sequence " + columnName + "_" + idField + "_seq; " +
|
||||
"alter table " + columnName + " alter column " + idField + " set default nextval(('" + columnName + "_" + idField + "_seq'::text)::regclass); "
|
||||
) );
|
||||
PSQLSequenceUtils.fixSequence( columnName, idField );
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in new issue