USE [TryNFeOnline]
GO

ALTER TABLE [dbo].[CartaoLote] ADD 
[idFaturaAntecipacao] [int] NULL,
[percentualTaxaAntecipacao] [decimal] (18,4) NULL
GO
ALTER TABLE [dbo].[configuracoes] ADD 
[idnObrigarCadastroCompletoParceiro] [bit] NULL,
[idnObrigarInformacaoEmailCadastroParceiro] [bit] NULL
GO
CREATE TABLE [dbo].[RegistroAtividades]
(
	[id] [int] IDENTITY (1,1) NOT NULL,
	[observacao] [varchar] (max) COLLATE Latin1_General_CI_AS NULL,
	[idOperador] [int] NULL,
	[idFilial] [int] NULL,
	[dataHora] [datetime] NOT NULL,
	[idCaixa] [int] NULL,
	[idNotaFiscal] [int] NULL,
	[idFatura] [int] NULL,
	[idOrdemServico] [int] NULL,
	[idPedido] [int] NULL,
	[idCondicional] [int] NULL,
	CONSTRAINT [PK_RegistroAtividades] PRIMARY KEY CLUSTERED
	(
		[id] ASC
	) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY  = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_Caixa] ON [dbo].[RegistroAtividades]
(
	[idCaixa] ASC
) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY  = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO

CREATE NONCLUSTERED INDEX [IX_Condicional] ON [dbo].[RegistroAtividades]
(
	[idCondicional] ASC
) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY  = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO

CREATE NONCLUSTERED INDEX [IX_Emitente] ON [dbo].[RegistroAtividades]
(
	[idFilial] ASC
) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY  = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO

CREATE NONCLUSTERED INDEX [IX_Fatura] ON [dbo].[RegistroAtividades]
(
	[idFatura] ASC
) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY  = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO

CREATE NONCLUSTERED INDEX [IX_NotaFiscal] ON [dbo].[RegistroAtividades]
(
	[idNotaFiscal] ASC
) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY  = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO

CREATE NONCLUSTERED INDEX [IX_Operador] ON [dbo].[RegistroAtividades]
(
	[idOperador] ASC
) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY  = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO

CREATE NONCLUSTERED INDEX [IX_OrdemServico] ON [dbo].[RegistroAtividades]
(
	[idOrdemServico] ASC
) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY  = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO

CREATE NONCLUSTERED INDEX [IX_Pedido] ON [dbo].[RegistroAtividades]
(
	[idPedido] ASC
) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY  = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO


ALTER TABLE [dbo].[CartaoLote] ADD CONSTRAINT [FK_CartaoLote_FaturaAntecipacao] FOREIGN KEY
	(
		[idFaturaAntecipacao]
	)
	REFERENCES [dbo].[Fatura]
	(
		[id]
	)
GO
INSERT INTO VERSAO(VERSAO, VERSAOATUALIZACAO, DATAATUALIZACAO) VALUES(363, 621, GETDATE());