spbgovbr / Sistema_Programa_de_Gestao_Susep

34 stars 48 forks source link

Ausência de colunas na criação do banco em 1. Criação da estrutura do banco de dados.sql #3

Open SrMouraSilva opened 3 years ago

SrMouraSilva commented 3 years ago

Olá, quando executo o 1. Criação da estrutura do banco de dados.sql no SQL Server 2019, estão ocorrendo os seguintes erros relacionado a colunas inexistentes nas tabelas criadas no mesmo arquivo:

db_1  | ALTER TABLE [dbo].[Pessoa]  WITH CHECK ADD  CONSTRAINT [FK_Pessoa_Cargo] FOREIGN KEY([cargoId])
db_1  | REFERENCES [dbo].[Cargo] ([cargoId])
db_1  |
db_1  | Msg 1769, Level 16, State 1, Server fa08337fa185, Line 1
db_1  | Foreign key 'FK_Pessoa_Cargo' references invalid column 'cargoId' in referencing table 'Pessoa'.
db_1  | Msg 1750, Level 16, State 1, Server fa08337fa185, Line 1
db_1  | Could not create constraint or index. See previous errors.
db_1  | ALTER TABLE [dbo].[Pessoa] CHECK CONSTRAINT [FK_Pessoa_Cargo]
db_1  |
db_1  | Msg 4917, Level 16, State 1, Server fa08337fa185, Line 1
db_1  | Constraint 'FK_Pessoa_Cargo' does not exist.
db_1  | Msg 4916, Level 16, State 1, Server fa08337fa185, Line 1
db_1  | Could not enable or disable the constraint. See previous errors.
db_1  | ALTER TABLE [dbo].[Pessoa]  WITH CHECK ADD  CONSTRAINT [FK_Pessoa_ClassePadrao] FOREIGN KEY([classePadraoId])
db_1  | REFERENCES [dbo].[ClassePadrao] ([classePadraoId])
db_1  |
db_1  | Msg 1769, Level 16, State 1, Server fa08337fa185, Line 1
db_1  | Foreign key 'FK_Pessoa_ClassePadrao' references invalid column 'classePadraoId' in referencing table 'Pessoa'.
db_1  | Msg 1750, Level 16, State 1, Server fa08337fa185, Line 1
db_1  | Could not create constraint or index. See previous errors.
db_1  | ALTER TABLE [dbo].[Pessoa] CHECK CONSTRAINT [FK_Pessoa_ClassePadrao]
db_1  |
db_1  | Msg 4917, Level 16, State 1, Server fa08337fa185, Line 1
db_1  | Constraint 'FK_Pessoa_ClassePadrao' does not exist.
db_1  | Msg 4916, Level 16, State 1, Server fa08337fa185, Line 1
db_1  | Could not enable or disable the constraint. See previous errors.
db_1  | ALTER TABLE [dbo].[Pessoa]  WITH CHECK ADD  CONSTRAINT [FK_Pessoa_Situacao_Pessoa] FOREIGN KEY([situacaoPessoaId])
db_1  | REFERENCES [dbo].[SituacaoPessoa] ([situacaoPessoaId])
db_1  | 
db_1  | Msg 1769, Level 16, State 1, Server fa08337fa185, Line 1
db_1  | Foreign key 'FK_Pessoa_Situacao_Pessoa' references invalid column 'situacaoPessoaId' in referencing table 'Pessoa'.
db_1  | Msg 1750, Level 16, State 1, Server fa08337fa185, Line 1
db_1  | Could not create constraint or index. See previous errors.
db_1  | ALTER TABLE [dbo].[Pessoa] CHECK CONSTRAINT [FK_Pessoa_Situacao_Pessoa]
db_1  |
db_1  | Msg 4917, Level 16, State 1, Server fa08337fa185, Line 1
db_1  | Constraint 'FK_Pessoa_Situacao_Pessoa' does not exist.
db_1  | Msg 4916, Level 16, State 1, Server fa08337fa185, Line 1
db_1  | Could not enable or disable the constraint. See previous errors.
db_1  | ALTER TABLE [dbo].[Pessoa]  WITH CHECK ADD  CONSTRAINT [FK_Pessoa_TipoFuncao] FOREIGN KEY([tipoFuncaoId])
db_1  | REFERENCES [dbo].[TipoFuncao] ([tipoFuncaoId])
db_1  |
db_1  | ALTER TABLE [dbo].[Pessoa] CHECK CONSTRAINT [FK_Pessoa_TipoFuncao]
db_1  |
db_1  | ALTER TABLE [dbo].[Pessoa]  WITH CHECK ADD  CONSTRAINT [FK_Pessoa_TipoVinculo] FOREIGN KEY([tipoVinculoId])
db_1  | REFERENCES [dbo].[TipoVinculo] ([tipoVinculoId])
db_1  |
db_1  | Msg 1769, Level 16, State 1, Server fa08337fa185, Line 1
db_1  | Foreign key 'FK_Pessoa_TipoVinculo' references invalid column 'tipoVinculoId' in referencing table 'Pessoa'.
db_1  | Msg 1750, Level 16, State 1, Server fa08337fa185, Line 1
db_1  | Could not create constraint or index. See previous errors.
db_1  | ALTER TABLE [dbo].[Pessoa] CHECK CONSTRAINT [FK_Pessoa_TipoVinculo]
db_1  |
db_1  | Msg 4917, Level 16, State 1, Server fa08337fa185, Line 1
db_1  | Constraint 'FK_Pessoa_TipoVinculo' does not exist.
db_1  | Msg 4916, Level 16, State 1, Server fa08337fa185, Line 1
db_1  | Could not enable or disable the constraint. See previous errors.
db_1  | ALTER TABLE [dbo].[Pessoa]  WITH CHECK ADD  CONSTRAINT [FK_Pessoa_Unidade] FOREIGN KEY([unidadeId])
db_1  | REFERENCES [dbo].[Unidade] ([unidadeId])
db_1  |
db_1  | ALTER TABLE [dbo].[Pessoa] CHECK CONSTRAINT [FK_Pessoa_Unidade]
db_1  |
db_1  | ALTER TABLE [dbo].[Unidade]  WITH CHECK ADD  CONSTRAINT [FK_Unidade_SituacaoUnidade] FOREIGN KEY([situacaoUnidadeId])
db_1  | REFERENCES [dbo].[SituacaoUnidade] ([situacaoUnidadeId])
db_1  |
db_1  | Msg 1767, Level 16, State 1, Server fa08337fa185, Line 1
db_1  | Foreign key 'FK_Unidade_SituacaoUnidade' references invalid table 'dbo.SituacaoUnidade'.
db_1  | Msg 1750, Level 16, State 1, Server fa08337fa185, Line 1
db_1  | Could not create constraint or index. See previous errors.
db_1  | ALTER TABLE [dbo].[Unidade] CHECK CONSTRAINT [FK_Unidade_SituacaoUnidade]
db_1  |
db_1  | Msg 4917, Level 16, State 1, Server fa08337fa185, Line 1
db_1  | Constraint 'FK_Unidade_SituacaoUnidade' does not exist.
db_1  | Msg 4916, Level 16, State 1, Server fa08337fa185, Line 1
db_1  | Could not enable or disable the constraint. See previous errors.
db_1  | ALTER TABLE [dbo].[Unidade]  WITH CHECK ADD  CONSTRAINT [FK_Unidade_TipoUnidade] FOREIGN KEY([tipoUnidadeId])
db_1  | REFERENCES [dbo].[TipoUnidade] ([tipoUnidadeId])
db_1  |
db_1  | Msg 1767, Level 16, State 1, Server fa08337fa185, Line 1
db_1  | Foreign key 'FK_Unidade_TipoUnidade' references invalid table 'dbo.TipoUnidade'.
db_1  | Msg 1750, Level 16, State 1, Server fa08337fa185, Line 1
db_1  | Could not create constraint or index. See previous errors.
db_1  | ALTER TABLE [dbo].[Unidade] CHECK CONSTRAINT [FK_Unidade_TipoUnidade]
db_1  |
db_1  | Msg 4917, Level 16, State 1, Server fa08337fa185, Line 1
db_1  | Constraint 'FK_Unidade_TipoUnidade' does not exist.
db_1  | Msg 4916, Level 16, State 1, Server fa08337fa185, Line 1
db_1  | Could not enable or disable the constraint. See previous errors.
db_1  | ALTER TABLE [dbo].[Unidade]  WITH CHECK ADD  CONSTRAINT [FK_Unidade_UF] FOREIGN KEY([ufId])
db_1  | REFERENCES [dbo].[UF] ([ufId])
db_1  |
db_1  | ALTER TABLE [dbo].[Unidade] CHECK CONSTRAINT [FK_Unidade_UF]
db_1  |
db_1  | ALTER TABLE [dbo].[Unidade]  WITH CHECK ADD  CONSTRAINT [FK_Unidade_UnidadePai] FOREIGN KEY([unidadeIdPai])
db_1  | REFERENCES [dbo].[Unidade] ([unidadeId])
db_1  |
db_1  | ALTER TABLE [dbo].[Unidade] CHECK CONSTRAINT [FK_Unidade_UnidadePai]
db_1  |
db_1  | ALTER TABLE [ProgramaGestao].[Assunto]  WITH CHECK ADD  CONSTRAINT [FK_Assunto_AssuntoPai] FOREIGN KEY([assuntoPaiId])
db_1  | REFERENCES [ProgramaGestao].[Assunto] ([assuntoId])
db_1  |
db_1  | ALTER TABLE [ProgramaGestao].[Assunto] CHECK CONSTRAINT [FK_Assunto_AssuntoPai]
db_1  |
db_1  | ALTER TABLE [ProgramaGestao].[Catalogo]  WITH CHECK ADD  CONSTRAINT [FK_Catalogo_Unidade] FOREIGN KEY([unidadeId])
db_1  | REFERENCES [dbo].[Unidade] ([unidadeId])

Isso aparentemente vai de encontro com a afirmação da documentação disponibilizada

O primeiro passo para instalar o sistema é criar a estrutura do banco de dados da aplicação. O script Criação da estrutura do banco de dados.sql executa todos os passos necessários para criar os objetos de banco.

Vocês passaram alguma versão antiga do código?

frozelio commented 3 years ago

Estou com o mesmo problema aqui! @SrMouraSilva