Centralize durable schema migration ownership
This commit is contained in:
parent
cc328237f4
commit
069f3813ae
5 changed files with 354 additions and 350 deletions
|
|
@ -25,5 +25,6 @@ tokio.workspace = true
|
|||
[dev-dependencies]
|
||||
pkcs8 = { version = "0.10.2", features = ["pem"] }
|
||||
rand = "0.8.5"
|
||||
remora-schema.workspace = true
|
||||
rsa = { version = "0.9.8", default-features = false, features = ["std", "pem"] }
|
||||
tokio = { workspace = true, features = ["macros", "rt-multi-thread", "sync", "time"] }
|
||||
|
|
|
|||
|
|
@ -1,10 +0,0 @@
|
|||
-- Stable principal mapping from OIDC issuer+subject pairs.
|
||||
-- Feature package remora-identity owns this schema.
|
||||
|
||||
CREATE TABLE principal_identities (
|
||||
principal_id TEXT PRIMARY KEY,
|
||||
issuer TEXT NOT NULL,
|
||||
subject TEXT NOT NULL,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
UNIQUE (issuer, subject)
|
||||
);
|
||||
|
|
@ -9,7 +9,6 @@
|
|||
|
||||
mod authz;
|
||||
mod error;
|
||||
mod migrate;
|
||||
mod oidc;
|
||||
mod principal;
|
||||
mod roles;
|
||||
|
|
@ -22,7 +21,6 @@ pub use authz::{
|
|||
resource_visibility,
|
||||
};
|
||||
pub use error::IdentityError;
|
||||
pub use migrate::{migrate, migrator};
|
||||
pub use oidc::{OidcConfig, OidcIdentityProvider, ZITADEL_PROJECT_ROLES_CLAIM, roles_from_names};
|
||||
pub use principal::{ExternalIdentity, Principal, principal_id_for};
|
||||
pub use roles::{
|
||||
|
|
|
|||
|
|
@ -1,19 +0,0 @@
|
|||
use remora_durable::DurableError;
|
||||
use sqlx::PgPool;
|
||||
|
||||
/// Separate migration history from the DurableStore substrate so feature-package
|
||||
/// versions do not collide with `remora-durable` in `_sqlx_migrations`.
|
||||
const MIGRATION_TABLE: &str = "_remora_identity_migrations";
|
||||
|
||||
pub async fn migrate(pool: &PgPool) -> Result<(), DurableError> {
|
||||
let mut migrator = sqlx::migrate!("./migrations");
|
||||
migrator.dangerous_set_table_name(MIGRATION_TABLE);
|
||||
migrator.run(pool).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn migrator() -> sqlx::migrate::Migrator {
|
||||
let mut migrator = sqlx::migrate!("./migrations");
|
||||
migrator.dangerous_set_table_name(MIGRATION_TABLE);
|
||||
migrator
|
||||
}
|
||||
|
|
@ -2,11 +2,9 @@ use std::time::Duration;
|
|||
|
||||
use base64::{Engine, engine::general_purpose::URL_SAFE_NO_PAD};
|
||||
use jsonwebtoken::{Algorithm, EncodingKey, Header, encode};
|
||||
use remora_durable::migrate as durable_migrate;
|
||||
use remora_durable::{PoolConfig, connect};
|
||||
use remora_identity::{
|
||||
OidcConfig, OidcIdentityProvider, migrate as identity_migrate, resolve_principal,
|
||||
};
|
||||
use remora_identity::{OidcConfig, OidcIdentityProvider, resolve_principal};
|
||||
use remora_schema::migrate as migrate_schema;
|
||||
use serde_json::{Value, json};
|
||||
use sqlx::PgPool;
|
||||
|
||||
|
|
@ -49,8 +47,7 @@ async fn test_pool() -> Option<PgPool> {
|
|||
)
|
||||
.await
|
||||
.expect("connect postgres");
|
||||
durable_migrate(&pool).await.expect("durable migrate");
|
||||
identity_migrate(&pool).await.expect("identity migrate");
|
||||
migrate_schema(&pool).await.expect("schema migrate");
|
||||
Some(pool)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue