
/*------ ATD 376123 ------*/
-------------------------------------------------------------------
							--- SQL ---
-------------------------------------------------------------------

IF NOT EXISTS (SELECT 1 FROM SYSOBJECTS WHERE xtype='U' AND name='ESTACAO')
BEGIN
				 
	CREATE TABLE ESTACAO(
				ID        INT IDENTITY NOT NULL,
				NOME      VARCHAR(254),
				PERFIL    NUMERIC(1,0) DEFAULT 0, 
				IDPERFIL  INT DEFAULT 0,
				CONSTRAINT PK_ESTACAO PRIMARY KEY (ID))
END
GO


IF NOT EXISTS (SELECT 1 FROM SYSOBJECTS WHERE xtype='U' AND name='GRUPOCONFIGURACAOESTACAO')
BEGIN
				 
	CREATE TABLE GRUPOCONFIGURACAOESTACAO (
				ID        INT IDENTITY NOT NULL,
				NOME      VARCHAR(254),
				CONSTRAINT PK_GRUPOCONFIGURACAOESTACAO PRIMARY KEY (ID))
END
GO

IF NOT EXISTS (SELECT 1 FROM SYSOBJECTS WHERE xtype='U' AND name='CONFIGURACAOESTACAO')
BEGIN
				 
	CREATE TABLE CONFIGURACAOESTACAO(
				ID         INT IDENTITY NOT NULL,
				IDESTACAO  INT,
				IDGRUPO    INT, 
				NOME       VARCHAR(254),
				VALOR      VARCHAR(254),
				TIPO       VARCHAR(50),
				PREVALECE  NUMERIC(1,0) DEFAULT 0,
				CONSTRAINT PK_CONFIGURACAOESTACAO PRIMARY KEY (ID))
END
GO

IF not EXISTS (SELECT 1 FROM GRUPOCONFIGURACAOESTACAO WHERE NOME = 'NFCE')
insert into GRUPOCONFIGURACAOESTACAO (nome) values ('NFCE')
go
