USE [TryNFeOnline]
GO

ALTER TABLE [dbo].[DashboardGrupos] ADD 
[idnInativo] [bit] NULL
GO
ALTER TABLE [dbo].[NFSeSubstituicao] ADD CONSTRAINT [FK_NFSeSubstituicao_notafiscal] FOREIGN KEY
	(
		[idNotaSubstituida]
	)
	REFERENCES [dbo].[notafiscal]
	(
		[id]
	)
GO
ALTER TABLE [dbo].[NFSeSubstituicao] ADD CONSTRAINT [FK_NFSeSubstituicao_notafiscal1] FOREIGN KEY
	(
		[idNotaSubstituta]
	)
	REFERENCES [dbo].[notafiscal]
	(
		[id]
	)
GO
UPDATE MDeNotas SET idEmitente = (SELECT nf.idEmitente from MDeConsultaNFe nf WHERE nf.id = idMDeConsulta) WHERE idEmitente is null
GO
INSERT INTO VERSAO(VERSAO, VERSAOATUALIZACAO, DATAATUALIZACAO) VALUES(397, 655, GETDATE());