Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[KW-Search] Fix sql for nodes tables creation #8926

Merged
merged 2 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions core/src/stores/migrations/20241125_nodes_table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ CREATE TABLE data_sources_nodes (
mime_type TEXT NOT NULL,
parents TEXT[] NOT NULL,
document BIGINT,
table BIGINT,
"table" BIGINT,
folder BIGINT,
FOREIGN KEY(data_source) REFERENCES data_sources(id),
FOREIGN KEY(document) REFERENCES data_sources_documents(id),
FOREIGN KEY(table) REFERENCES tables(id),
FOREIGN KEY("table") REFERENCES tables(id),
FOREIGN KEY(folder) REFERENCES data_sources_folders(id),
CONSTRAINT data_sources_nodes_document_id_table_id_folder_id_check CHECK (
(document IS NOT NULL AND table IS NULL AND folder IS NULL) OR
(document IS NULL AND table IS NOT NULL AND folder IS NULL) OR
(document IS NULL AND table IS NULL AND folder IS NOT NULL)
(document IS NOT NULL AND "table" IS NULL AND folder IS NULL) OR
(document IS NULL AND "table" IS NOT NULL AND folder IS NULL) OR
(document IS NULL AND "table" IS NULL AND folder IS NOT NULL)
)
);

Expand Down
10 changes: 5 additions & 5 deletions core/src/stores/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,16 +516,16 @@ pub const POSTGRES_TABLES: [&'static str; 16] = [
mime_type TEXT NOT NULL,
parents TEXT[] NOT NULL,
document BIGINT,
table BIGINT,
\"table\" BIGINT,
folder BIGINT,
FOREIGN KEY(data_source) REFERENCES data_sources(id),
FOREIGN KEY(document) REFERENCES data_sources_documents(id),
FOREIGN KEY(table) REFERENCES tables(id),
FOREIGN KEY(\"table\") REFERENCES tables(id),
FOREIGN KEY(folder) REFERENCES data_sources_folders(id),
CONSTRAINT data_sources_nodes_document_id_table_id_folder_id_check CHECK (
(document IS NOT NULL AND table IS NULL AND folder IS NULL) OR
(document IS NULL AND table IS NOT NULL AND folder IS NULL) OR
(document IS NULL AND table IS NULL AND folder IS NOT NULL)
(document IS NOT NULL AND \"table\" IS NULL AND folder IS NULL) OR
(document IS NULL AND \"table\" IS NOT NULL AND folder IS NULL) OR
(document IS NULL AND \"table\" IS NULL AND folder IS NOT NULL)
)
);",
];
Expand Down
Loading