diff --git a/packages/backend/native-utils/scylla-migration/src/config.rs b/packages/backend/native-utils/scylla-migration/src/config.rs index 0064d9d2dd..b2a26e78ee 100644 --- a/packages/backend/native-utils/scylla-migration/src/config.rs +++ b/packages/backend/native-utils/scylla-migration/src/config.rs @@ -13,6 +13,14 @@ pub struct ScyllaConfig { pub nodes: Vec, pub keyspace: String, pub replication_factor: i32, + pub credentials: Option, +} + +#[derive(Debug, PartialEq, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct Credentials { + pub username: String, + pub password: String, } #[derive(Debug, PartialEq, Deserialize)] diff --git a/packages/backend/native-utils/scylla-migration/src/migrator.rs b/packages/backend/native-utils/scylla-migration/src/migrator.rs index 14ad19d6fd..967e849673 100644 --- a/packages/backend/native-utils/scylla-migration/src/migrator.rs +++ b/packages/backend/native-utils/scylla-migration/src/migrator.rs @@ -39,10 +39,14 @@ impl Migrator { } pub(crate) async fn new(dir: PathBuf, config: &ScyllaConfig) -> Result { - let session = SessionBuilder::new() - .known_nodes(&config.nodes) - .build() - .await?; + let mut builder = SessionBuilder::new() + .known_nodes(&config.nodes); + + if let Some(credentials) = &config.credentials { + builder = builder.user(&credentials.username, &credentials.password); + } + + let session = builder.build().await?; session .query( diff --git a/packages/backend/native-utils/scylla-migration/src/setup.rs b/packages/backend/native-utils/scylla-migration/src/setup.rs index b96992be38..a952703c13 100644 --- a/packages/backend/native-utils/scylla-migration/src/setup.rs +++ b/packages/backend/native-utils/scylla-migration/src/setup.rs @@ -32,10 +32,18 @@ impl Initializer { scylla_conf: &ScyllaConfig, postgres_conf: &DbConfig, ) -> Result { - let session = SessionBuilder::new() - .known_nodes(&scylla_conf.nodes) - .build() - .await?; + + let mut builder = SessionBuilder::new() + .known_nodes(&scylla_conf.nodes); + + match &scylla_conf.credentials { + Some(credentials) => { + builder = builder.user(&credentials.username, &credentials.password); + }, + None => {} + } + + let session = builder.build().await?; session.use_keyspace(&scylla_conf.keyspace, true).await?; let conn_url = format!(