mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-01 17:00:21 +08:00
Update Postgres bootstrap for audit admin role
This commit is contained in:
@@ -91,6 +91,7 @@ END $mig$;
|
||||
DO $mig$ BEGIN
|
||||
CREATE TYPE public.userrole AS ENUM (
|
||||
'admin',
|
||||
'audit_admin',
|
||||
'user'
|
||||
);
|
||||
EXCEPTION WHEN duplicate_object THEN NULL;
|
||||
|
||||
@@ -7,7 +7,7 @@ use tracing::info;
|
||||
// Generated by build.rs from schema/bootstrap/postgres.
|
||||
pub(crate) static EMPTY_DATABASE_SNAPSHOT_SQL: &str =
|
||||
include_str!(concat!(env!("OUT_DIR"), "/empty_database_snapshot.sql"));
|
||||
pub(crate) const EMPTY_DATABASE_SNAPSHOT_CUTOFF_VERSION: i64 = 20260512000000;
|
||||
pub(crate) const EMPTY_DATABASE_SNAPSHOT_CUTOFF_VERSION: i64 = 20260515000000;
|
||||
|
||||
const PUBLIC_BASE_TABLE_COUNT_SQL: &str = r#"
|
||||
SELECT COUNT(*)::BIGINT
|
||||
|
||||
@@ -302,12 +302,14 @@ fn empty_database_snapshot_covers_current_cutoff_versions() {
|
||||
20260511120000,
|
||||
20260511130000,
|
||||
20260512000000,
|
||||
20260515000000,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn empty_database_snapshot_sql_includes_usage_body_blobs() {
|
||||
fn empty_database_snapshot_sql_includes_usage_body_blobs_and_audit_admin_role() {
|
||||
assert!(EMPTY_DATABASE_SNAPSHOT_SQL.contains("'audit_admin'"));
|
||||
assert!(
|
||||
EMPTY_DATABASE_SNAPSHOT_SQL.contains("CREATE TABLE IF NOT EXISTS public.usage_body_blobs")
|
||||
);
|
||||
@@ -1096,6 +1098,7 @@ fn pending_migrations_from_applied_skips_versions_already_applied() {
|
||||
20260511120000,
|
||||
20260511130000,
|
||||
20260512000000,
|
||||
20260515000000,
|
||||
]
|
||||
);
|
||||
}
|
||||
@@ -1423,6 +1426,17 @@ async fn prepare_database_for_startup_bootstraps_clean_database() {
|
||||
.await
|
||||
.expect("api_keys.total_tokens lookup should succeed"));
|
||||
|
||||
let audit_admin_exists: bool = query_scalar(
|
||||
"SELECT EXISTS (SELECT 1 FROM pg_enum WHERE enumtypid = 'public.userrole'::regtype AND enumlabel = 'audit_admin')",
|
||||
)
|
||||
.fetch_one(&pool)
|
||||
.await
|
||||
.expect("public.userrole audit_admin lookup should succeed");
|
||||
assert!(
|
||||
audit_admin_exists,
|
||||
"fresh database snapshot should include public.userrole.audit_admin"
|
||||
);
|
||||
|
||||
let applied_count: i64 = query_scalar("SELECT COUNT(*)::BIGINT FROM public._sqlx_migrations")
|
||||
.fetch_one(&pool)
|
||||
.await
|
||||
|
||||
Reference in New Issue
Block a user