diff --git a/consumer/src/db/copy.rs b/consumer/src/db/copy.rs index 6dd4d057..1b622991 100644 --- a/consumer/src/db/copy.rs +++ b/consumer/src/db/copy.rs @@ -384,13 +384,13 @@ pub async fn copy_records( let writer = conn .copy_in("COPY records_tmp (at_uri, did, cid) FROM STDIN (FORMAT binary)") .await?; - let writer = BinaryCopyInWriter::new(writer, &[Type::TEXT, Type::TEXT, Type::TEXT]); + let writer = BinaryCopyInWriter::new(writer, &[Type::TEXT, Type::TEXT, Type::BYTEA]); pin_mut!(writer); for (at_uri, cid) in data { let writer = writer.as_mut(); - writer.write(&[&at_uri, &did, &cid.to_string()]).await?; + writer.write(&[&at_uri, &did, &cid.to_bytes()]).await?; } writer.finish().await?; diff --git a/consumer/src/db/record.rs b/consumer/src/db/record.rs index 29d629d0..9e5e55e1 100644 --- a/consumer/src/db/record.rs +++ b/consumer/src/db/record.rs @@ -13,7 +13,7 @@ pub async fn record_upsert( ) -> PgExecResult { conn.execute( "INSERT INTO records (at_uri, did, cid) VALUES ($1, $2, $3) ON CONFLICT (at_uri) DO UPDATE SET cid=EXCLUDED.cid", - &[&at_uri, &repo, &cid.to_string()], + &[&at_uri, &repo, &cid.to_bytes()], ).await } diff --git a/migrations/2025-05-03-103435_records/up.sql b/migrations/2025-05-03-103435_records/up.sql index 51923b7c..1a160dbb 100644 --- a/migrations/2025-05-03-103435_records/up.sql +++ b/migrations/2025-05-03-103435_records/up.sql @@ -1,7 +1,7 @@ create table records ( at_uri text not null primary key, - cid text not null, + cid bytea not null, did text not null, indexed_at timestamp not null default now() diff --git a/parakeet-db/src/schema.rs b/parakeet-db/src/schema.rs index a4219d5f..0cf128ac 100644 --- a/parakeet-db/src/schema.rs +++ b/parakeet-db/src/schema.rs @@ -271,7 +271,7 @@ diesel::table! { diesel::table! { records (at_uri) { at_uri -> Text, - cid -> Text, + cid -> Bytea, did -> Text, indexed_at -> Timestamp, }