You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have some tables with multiple columns in their primary key like so:
CREATE SCHEMA [MySchema]
GO
CREATE TABLE [MySchema].[MyTable]
(
[TenantId] UNIQUEIDENTIFIER NOT NULL,
[MyTableId] UNIQUEIDENTIFIER NOT NULL,
[Name] NVARCHAR(200) NOT NULL,
CONSTRAINT [PK_MySchema_TableA] PRIMARY KEY CLUSTERED ([TenantId], [MyTableId])
)
CREATE TABLE [MySchema].[MySubTable]
(
[TenantId] UNIQUEIDENTIFIER NOT NULL,
[MyTableId] UNIQUEIDENTIFIER NOT NULL,
[MySubTableId] UNIQUEIDENTIFIER NOT NULL,
[Name] NVARCHAR(200) NOT NULL,
CONSTRAINT [PK_MySchema_MySubTable] PRIMARY KEY CLUSTERED ([TenantId], [MyTableId], [MySubTableId]),
CONSTRAINT [FK_MySchema_MySubTable_MyTable] FOREIGN KEY (TenantId, MyTableId) REFERENCES [MySchema].[MyTable] (TenantId, MyTableId)
)
GO
If I run this with or without any options, it will create the primary keys correctly, but for some reason it won't properly group the foreign key results from the MSSQL query, and attempts to create separate foreign keys:
NOTICE CREATE UNIQUE INDEX PK_MySchema_TableA ON my_schema.my_table (tenant_id, my_table_id);
NOTICE CREATE UNIQUE INDEX PK_MySchema_MySubTable ON my_schema.my_sub_table (tenant_id, my_table_id, my_sub_table_id);
NOTICE Completing PostgreSQL database.
NOTICE Reset sequences
NOTICE ALTER TABLE my_schema.my_table ADD PRIMARY KEY USING INDEX PK_MySchema_TableA;
NOTICE ALTER TABLE my_schema.my_sub_table ADD PRIMARY KEY USING INDEX PK_MySchema_MySubTable;
NOTICE ALTER TABLE my_schema.my_sub_table ADD CONSTRAINT fk__my_schema__my_sub_table__my_table FOREIGN KEY(tenant_id) REFERENCES my_schema.my_table(tenant_id) ON UPDATE NO ACTION ON DELETE NO ACTION
ERROR PostgreSQL Database error 42830: there is no unique constraint matching given keys for referenced table "my_table"
QUERY: ALTER TABLE my_schema.my_sub_table ADD CONSTRAINT fk__my_schema__my_sub_table__my_table FOREIGN KEY(tenant_id) REFERENCES my_schema.my_table(tenant_id) ON UPDATE NO ACTION ON DELETE NO
ACTION
QUERY: ALTER TABLE my_schema.my_sub_table ADD CONSTRAINT fk__my_schema__my_sub_table__my_table FOREIGN KEY(my_table_id) REFERENCES my_schema.my_table(my_table_id) ON UPDATE NO ACTION ON DELETE NO ACTION
I have zero experience in lisp, but tried to follow the code, and it seems like it's setup to build up the foreign key definition columns opposed to creating separate indexes per record returned from MSSQL, but I'm not sure exactly where the issue would be
The text was updated successfully, but these errors were encountered:
I have some tables with multiple columns in their primary key like so:
If I run this with or without any options, it will create the primary keys correctly, but for some reason it won't properly group the foreign key results from the MSSQL query, and attempts to create separate foreign keys:
I have zero experience in lisp, but tried to follow the code, and it seems like it's setup to build up the foreign key definition columns opposed to creating separate indexes per record returned from MSSQL, but I'm not sure exactly where the issue would be
The text was updated successfully, but these errors were encountered: