
/*------ ATD 422863 ------*/
IF NOT EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'PEDIDO_ECOMMERCE' AND COLUMN_NAME = 'CODIGOFRANQUIA')
begin
ALTER TABLE PEDIDO_ECOMMERCE ADD CODIGOFRANQUIA VARCHAR(3)
end
go

IF NOT EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'PONTO_RETIRADA_ECOMMERCE' AND COLUMN_NAME = 'IDFRANQUIA')
begin
ALTER TABLE PONTO_RETIRADA_ECOMMERCE ADD IDFRANQUIA INT
end
GO

IF NOT EXISTS (SELECT 1 FROM SYSINDEXES SI
					 JOIN SYSINDEXKEYS SIK ON SIK.INDID = SI.INDID
					 JOIN SYSOBJECTS T ON T.ID = SIK.ID AND T.ID = SI.ID 
					WHERE SI.NAME = 'FRANQUIA_ECOMMERCE_IDX2' AND T.NAME = 'FRANQUIA_ECOMMERCE')
begin
	CREATE UNIQUE INDEX FRANQUIA_ECOMMERCE_IDX2 ON FRANQUIA_ECOMMERCE(RPLATAFORMA,CODIGO)
end
GO