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
Fixed an error when creating structure.sql file for a database, when it is necessary to create a relation for tables that refer to each other.
Fixed ussues Metasql metarhia#291
Describe the bug
https://github.com/metatech-university/NodeJS-Application/blob/5749fece58d3c1c060ea668fe1a354d133f708eb/schemas/Identifier.js#L4
One-to-one relations should be to the Entity table. So line 4 should be:
entity: '?Entity',
in structure.sql file:
https://github.com/metatech-university/NodeJS-Application/blob/5749fece58d3c1c060ea668fe1a354d133f708eb/db/structure.sql#L9
So line 9 should be:
ALTER TABLE "Identifier" ADD CONSTRAINT "fkIdentifierEntity" FOREIGN KEY ("entityId") REFERENCES "Entity" ("id");
But this generates an error - since the Entity table has not yet been created.
To Reproduce
Identifier.js
({
Entity: {},
entity: '?Entity',
});
Actual behavior
generates in structure.sql file,
CREATE TABLE "Identifier" (
"id" bigint generated always as identity,
"entityId" bigint NULL,
. . .
);
. . .
ALTER TABLE "Identifier" ADD CONSTRAINT "fkIdentifierEntity" FOREIGN KEY ("entityId") REFERENCES "Entity" ("id");
. . .
. . .
CREATE TABLE "Entity" (
. . .
);
Expected behavior
The line must be generated after the Entity table creation line:
generates in structure.sql file,
CREATE TABLE "Identifier" (
. . .
);
. . .
CREATE TABLE "Entity" (
. . .
);
ALTER TABLE "Identifier" ADD CONSTRAINT "fkIdentifierEntity" FOREIGN KEY ("entityId") REFERENCES "Entity" ("id");
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: