INSERT INTO versao_sistema (Dominio, Seq , Versao, DH_Atualizacao) SELECT 0, (SELECT (IFNULL(MAX(Seq), 0) + 1) FROM versao_sistema WHERE Dominio = 0 LIMIT 1),  "15.17.00", now() FROM dominio LIMIT 1;

INSERT INTO versao_sistema (Dominio, Seq , Versao, DH_Atualizacao) SELECT Dominio AS T_Dominio, (SELECT (IFNULL(MAX(Seq), 0)+1) FROM versao_sistema WHERE Dominio = T_Dominio LIMIT 1), "15.17.00",  now() FROM dominio WHERE Dominio > 0;


ALTER TABLE comanda_item_temp
	ADD COLUMN id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT FIRST,
	DROP PRIMARY KEY,
	ADD PRIMARY KEY (id),
	ADD INDEX IDX_CHAVE (Dominio, Empresa, Nr_Comanda, Seq, Usuario);
