fix(transfer): preserve PostgreSQL bytea migration

This commit is contained in:
t8y2 committed 2026-06-26 02:05:49 +08:00
1 parent dff94d60f5
commit 54e0393ab3
2 files changed
+80 -1

No files matched your search

@@ -110,6 +110,14 @@ async fn live_postgres_transfer_preserves_data_and_schema_objects() {
)",
source_schema, source_schema
),
format!(
"CREATE TABLE \"{}\".\"files\" (\
\"id\" integer PRIMARY KEY,\
\"payload\" bytea NOT NULL,\
\"note\" text NOT NULL\
)",
source_schema
),
format!(
"CREATE INDEX \"users_display_name_idx\" ON \"{}\".\"users\" USING btree (lower(display_name))",
source_schema
@@ -139,6 +147,11 @@ async fn live_postgres_transfer_preserves_data_and_schema_objects() {
('beta@example.com', 'disabled', false, 'Beta')",
source_schema
),
format!(
"INSERT INTO \"{}\".\"files\" (\"id\", \"payload\", \"note\") VALUES \
(1, decode('48656c6c6f', 'hex'), '0x48656c6c6f')",
source_schema
),
format!(
"CREATE VIEW \"{}\".\"active_users\" AS \
SELECT \"id\", \"email\", \"display_name\" FROM \"{}\".\"users\" WHERE \"active\"",
@@ -192,7 +205,7 @@ async fn live_postgres_transfer_preserves_data_and_schema_objects() {
target_connection_id: target_connection_id.to_string(),
target_database: target_database.clone(),
target_schema: target_schema.clone(),
tables: vec!["users".to_string(), "audit_logs".to_string()],
tables: vec!["users".to_string(), "audit_logs".to_string(), "files".to_string()],
create_table: true,
mode: TransferMode::Append,
target_table_name_case: TransferTableNameCase::Preserve,
@@ -229,6 +242,27 @@ async fn live_postgres_transfer_preserves_data_and_schema_objects() {
query_scalar(&target_pool, &format!("SELECT count(*) FROM \"{}\".\"audit_logs\"", target_schema)).await,
json!(2)
);
assert_eq!(
query_scalar(
&target_pool,
&format!("SELECT octet_length(\"payload\") FROM \"{}\".\"files\" WHERE \"id\" = 1", target_schema)
)
.await,
json!(5)
);
assert_eq!(
query_scalar(
&target_pool,
&format!("SELECT encode(\"payload\", 'hex') FROM \"{}\".\"files\" WHERE \"id\" = 1", target_schema)
)
.await,
json!("48656c6c6f")
);
assert_eq!(
query_scalar(&target_pool, &format!("SELECT \"note\" FROM \"{}\".\"files\" WHERE \"id\" = 1", target_schema))
.await,
json!("0x48656c6c6f")
);
assert_eq!(
query_scalar(
&target_pool,