Skip to content

Commit d936d47

Browse files
committed
Don't use migration file name but a ':database' suffix
Signed-off-by: Ryan Levick <[email protected]>
1 parent f83eaa5 commit d936d47

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

crates/trigger/src/runtime_config/sqlite.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,16 @@ async fn execute_statements(
5151
}
5252

5353
for m in statements {
54-
if let Some(file) = m.strip_prefix('@') {
55-
let database = file.strip_suffix(".sql").unwrap_or(file);
54+
if let Some(config) = m.strip_prefix('@') {
55+
let config = config.trim();
56+
let (file, database) = match config.split_once(':') {
57+
Some((file, database)) if database.trim().is_empty() => (file.trim(), "default"),
58+
Some((file, database)) => (file.trim(), database.trim()),
59+
None => (config, "default"),
60+
};
5661
let database = databases.get(database).with_context(|| {
5762
format!(
58-
"based on the sql file '{file}' a registered database named '{database}' was expected but not found. The registered databases are '{:?}'", databases.keys()
63+
"based on the '@{config}' a registered database named '{database}' was expected but not found. The registered databases are '{:?}'", databases.keys()
5964
)
6065
})?;
6166
let sql = std::fs::read_to_string(file).with_context(|| {

0 commit comments

Comments
 (0)