USE [TryNFeOnline]
GO
ALTER TABLE [dbo].[parceiro] ADD 
[telefoneConjuge] [varchar] (25) COLLATE Latin1_General_CI_AS NULL
GO
ALTER TABLE [dbo].[ParceiroDependentes] ADD 
[dataNascimento] [date] NULL,
[telefone] [varchar] (20) COLLATE Latin1_General_CI_AS NULL
GO
ALTER TABLE [dbo].[produto] ADD 
[qtdProdutoOrigem] [decimal] (18,4) NULL
GO
ALTER TABLE [dbo].[configuracoes] ADD 
[idnExibirProdutosQueNaoControlamEstoqueImportacaoXML] [bit] NULL,
[versaoMinimaAppComandas] [int] NULL,
[versaoMinimaAppPedidos] [int] NULL,
[versaoMinimaAppOS] [int] NULL
GO
ALTER TABLE [dbo].[notafiscal] ADD 
[percentualComissaoRepresentante] [decimal] (18,4) NULL,
[percentualDescontoComissao] [decimal] (18,4) NULL
GO
ALTER TABLE [dbo].[operacao] ADD 
[dataUltimaAlteracao] [datetime] NULL,
[idnUtilizaNoApp] [bit] NULL
GO
CREATE TABLE [dbo].[ObservacoesPreDefinidas]
(
	[id] [int] IDENTITY (1,1) NOT NULL,
	[descricao] [varchar] (200) COLLATE Latin1_General_CI_AS NOT NULL,
	CONSTRAINT [PK_ObservacoesPreDefinidas] 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
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE TRIGGER [dbo].[TGR_OPERACAO_AD]
   ON  [dbo].[operacao]
   AFTER DELETE
AS 
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;
    DECLARE @ID int
	
	SELECT @ID = id from deleted
	
	INSERT INTO RegistrosRemovidos([idRegistroExcluido],[indTipoRegistro],[dataExclusao]) VALUES (@ID, 'Operacao', GETDATE())

END
GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE TRIGGER [dbo].[TGR_OPERACAO_AU]
   ON  [dbo].[operacao]
   AFTER INSERT, UPDATE
AS 
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    DECLARE @ID int
	
	SELECT @ID = id from inserted
	
	UPDATE operacao set dataUltimaAlteracao = GETDATE()
	where id = @ID

END
GO
UPDATE configuracoes SET versaoMinimaAppPedidos = 2
GO
UPDATE configuracoes SET versaoMinimaAppComandas = 6
GO
INSERT INTO VERSAO(VERSAO, VERSAOATUALIZACAO, DATAATUALIZACAO) VALUES(354, 612, GETDATE());