Skip to content

Commit

Permalink
Remove source_url from data_sources_documents (#10085)
Browse files Browse the repository at this point in the history
* read the source_url from data_sources_nodes instead of data_sources_documents

* prevent writes to data_sources_documents.source_url

* add a migration script

* remove the column from the init_db
  • Loading branch information
aubin-tchoi authored Jan 27, 2025
1 parent bae93cd commit 217e0d4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE data_sources_documents DROP COLUMN IF EXISTS source_url;
9 changes: 4 additions & 5 deletions core/src/stores/postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1336,7 +1336,7 @@ impl Store for PostgresStore {
None => {
c.query(
"SELECT dsd.id, dsd.created, dsd.timestamp, dsd.tags_array, dsn.parents, \
dsd.source_url, dsd.hash, dsd.text_size, dsd.chunk_count, dsn.title, \
dsn.source_url, dsd.hash, dsd.text_size, dsd.chunk_count, dsn.title, \
dsn.mime_type, dsn.provider_visibility \
FROM data_sources_documents dsd \
INNER JOIN data_sources_nodes dsn ON dsn.document=dsd.id \
Expand All @@ -1349,7 +1349,7 @@ impl Store for PostgresStore {
Some(version_hash) => {
c.query(
"SELECT dsd.id, dsd.created, dsd.timestamp, dsd.tags_array, dsn.parents, \
dsd.source_url, dsd.hash, dsd.text_size, dsd.chunk_count, dsn.title, \
dsn.source_url, dsd.hash, dsd.text_size, dsd.chunk_count, dsn.title, \
dsn.mime_type, dsn.provider_visibility \
FROM data_sources_documents dsd \
INNER JOIN data_sources_nodes dsn ON dsn.document=dsd.id \
Expand Down Expand Up @@ -1867,7 +1867,7 @@ impl Store for PostgresStore {
.prepare(
"INSERT INTO data_sources_documents \
(id, data_source, created, document_id, timestamp, tags_array, \
source_url, hash, text_size, chunk_count, status) \
hash, text_size, chunk_count, status) \
VALUES (DEFAULT, $1, $2, $3, $4, $5, $6, $7, $8, $9, $10) \
RETURNING id, created",
)
Expand All @@ -1882,7 +1882,6 @@ impl Store for PostgresStore {
&create_params.document_id,
&(create_params.timestamp as i64),
&create_params.tags,
&create_params.source_url,
&create_params.hash,
&(create_params.text_size as i64),
&(create_params.chunk_count as i64),
Expand Down Expand Up @@ -2009,7 +2008,7 @@ impl Store for PostgresStore {

let sql = format!(
"SELECT dsd.id, dsd.created, dsd.document_id, dsd.timestamp, dsd.tags_array, \
dsn.parents, dsd.source_url, dsd.hash, dsd.text_size, dsd.chunk_count, \
dsn.parents, dsn.source_url, dsd.hash, dsd.text_size, dsd.chunk_count, \
dsn.title, dsn.mime_type, dsn.provider_visibility \
FROM data_sources_documents dsd \
INNER JOIN data_sources_nodes dsn ON dsn.document=dsd.id \
Expand Down
1 change: 0 additions & 1 deletion core/src/stores/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,6 @@ pub const POSTGRES_TABLES: [&'static str; 16] = [
document_id TEXT NOT NULL,
timestamp BIGINT NOT NULL,
tags_array TEXT[] NOT NULL,
source_url TEXT,
hash TEXT NOT NULL,
text_size BIGINT NOT NULL,
chunk_count BIGINT NOT NULL,
Expand Down

0 comments on commit 217e0d4

Please sign in to comment.