mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 01:10:23 +08:00
fix(data): baseline 迁移 search_path 改为事务级作用域,修复 sqlx 迁移表访问问题
This commit is contained in:
@@ -28,7 +28,7 @@ SET client_encoding = 'UTF8';
|
|||||||
|
|
||||||
SET standard_conforming_strings = on;
|
SET standard_conforming_strings = on;
|
||||||
|
|
||||||
SELECT pg_catalog.set_config('search_path', '', false);
|
SELECT pg_catalog.set_config('search_path', '', true);
|
||||||
|
|
||||||
SET check_function_bodies = false;
|
SET check_function_bodies = false;
|
||||||
|
|
||||||
@@ -4585,4 +4585,3 @@ END $mig$;
|
|||||||
-- PostgreSQL database dump complete
|
-- PostgreSQL database dump complete
|
||||||
--
|
--
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -162,3 +162,29 @@ fn validate_applied_migrations(
|
|||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::MIGRATOR;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn baseline_migration_keeps_empty_search_path_transaction_local() {
|
||||||
|
let baseline = MIGRATOR
|
||||||
|
.iter()
|
||||||
|
.find(|migration| migration.version == 20260403000000)
|
||||||
|
.expect("baseline migration should be embedded");
|
||||||
|
|
||||||
|
assert!(
|
||||||
|
baseline
|
||||||
|
.sql
|
||||||
|
.contains("SELECT pg_catalog.set_config('search_path', '', true);"),
|
||||||
|
"baseline migration must keep empty search_path transaction-local so sqlx bookkeeping can still access _sqlx_migrations",
|
||||||
|
);
|
||||||
|
assert!(
|
||||||
|
!baseline
|
||||||
|
.sql
|
||||||
|
.contains("SELECT pg_catalog.set_config('search_path', '', false);"),
|
||||||
|
"baseline migration must not persist an empty search_path at session scope",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user