pr_01m47d15m3e54sn21z27rpy5n9/services/integrations/src/rename.rs

26 lines1,119 bytesCodeBlame
1//! A workspace renamed: rows kept under its old slug move to the one it
2//! has now. See `g1t_kit::rename`.
3
4/// `?1` is the current slug, `?2` a stale one.
5pub const STATEMENTS: &[&str] = &[
6 "UPDATE connections SET workspace = ?1 WHERE workspace = ?2",
7 "UPDATE links SET workspace = ?1 WHERE workspace = ?2",
8 "UPDATE links SET repo = ?1 || substr(repo, length(?2) + 1) WHERE substr(repo, 1, length(?2) + 1) = ?2 || '/'",
9 "UPDATE model_sessions SET workspace = ?1 WHERE workspace = ?2",
10 "UPDATE model_sessions SET repo = ?1 || substr(repo, length(?2) + 1) WHERE substr(repo, 1, length(?2) + 1) = ?2 || '/'",
11 "UPDATE deliveries SET issue = ?1 || substr(issue, length(?2) + 1) WHERE substr(issue, 1, length(?2) + 1) = ?2 || '/'",
12 "UPDATE OR IGNORE model_routes SET workspace = ?1 WHERE workspace = ?2",
13 "DELETE FROM model_routes WHERE workspace = ?2",
14];
15
16#[cfg(test)]
17mod tests {
18 use super::STATEMENTS;
19
20 #[test]
21 fn every_statement_takes_the_two_slugs() {
22 for sql in STATEMENTS {
23 assert_eq!(g1t_kit::rename::parameters(sql), 2, "{sql}");
24 }
25 }
26}