6 let mut test = Test::new("Rename table");
10 name = "create_users_table"
23 test.second_migration(
25 name = "rename_users_table_to_customers"
30 new_name = "customers"
34 test.intermediate(|old_db, new_db| {
35 // Make sure inserts work using both the old and new name
37 .simple_query("INSERT INTO users(id) VALUES (1)")
40 .simple_query("INSERT INTO customers(id) VALUES (2)")
43 // Ensure the table can be queried using both the old and new name
44 let expected: Vec<i32> = vec![1, 2];
48 .query("SELECT id FROM users ORDER BY id", &[])
51 .map(|row| row.get::<_, i32>("id"))
52 .collect::<Vec<i32>>()
57 .query("SELECT id FROM customers ORDER BY id", &[])
60 .map(|row| row.get::<_, i32>("id"))
61 .collect::<Vec<i32>>()
64 // Ensure the table can't be queried using the wrong name for the schema
65 assert!(old_db.simple_query("SELECT id FROM customers").is_err());
66 assert!(new_db.simple_query("SELECT id FROM users").is_err());
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list