Skip to content

Commit

Permalink
Conditionally create schema when creating queue on extensionless
Browse files Browse the repository at this point in the history
  • Loading branch information
v0idpwn committed Sep 13, 2023
1 parent aaa4a5d commit 92f418e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions core/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ pub fn create_archive(name: CheckedName<'_>) -> Result<String, PgmqError> {
))
}

pub fn create_schema() -> String {
format!("CREATE SCHEMA IF NOT EXISTS {PGMQ_SCHEMA}")
}

pub fn create_meta() -> String {
format!(
"
Expand Down
2 changes: 2 additions & 0 deletions pgmq-rs/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use pgmq_core::{errors, query, util};
pub fn init_queue_client_only(name: &str) -> Result<Vec<String>, errors::PgmqError> {
let name = util::CheckedName::new(name)?;
Ok(vec![
query::create_schema(),
query::create_meta(),
query::create_queue(name)?,
query::create_index(name)?,
Expand All @@ -19,6 +20,7 @@ pub fn init_queue_client_only(name: &str) -> Result<Vec<String>, errors::PgmqErr
pub fn destroy_queue_client_only(name: &str) -> Result<Vec<String>, errors::PgmqError> {
let name = util::CheckedName::new(name)?;
Ok(vec![
query::create_schema(),
query::drop_queue(name)?,
query::drop_queue_archive(name)?,
query::delete_queue_metadata(name)?,
Expand Down

0 comments on commit 92f418e

Please sign in to comment.