6 let mut test = Test::new("Remove column");
10 name = "create_user_table"
27 test.second_migration(
29 name = "remove_name_column"
32 type = "remove_column"
35 down = "'TEST_DOWN_VALUE'"
39 test.intermediate(|old_db, new_db| {
40 // Insert using old schema and ensure it can be retrieved through new schema
42 .simple_query("INSERT INTO users(id, name) VALUES (1, 'John Doe')")
45 .query("SELECT id FROM users WHERE id = 1", &[])
47 assert_eq!(1, results.len());
48 assert_eq!(1, results[0].get::<_, i32>("id"));
50 // Ensure the name column is not accesible through the new schema
51 assert!(new_db.query("SELECT id, name FROM users", &[]).is_err());
53 // Insert using new schema and ensure the down function is correctly applied
55 .simple_query("INSERT INTO users(id) VALUES (2)")
58 .query_opt("SELECT name FROM users WHERE id = 2", &[])
61 Some("TEST_DOWN_VALUE"),
62 result.as_ref().map(|row| row.get("name"))
70fn remove_column_with_index() {
71 let mut test = Test::new("Remove column");
75 name = "create_user_table"
100 test.second_migration(
102 name = "remove_name_column"
105 type = "remove_column"
108 down = "'TEST_DOWN_VALUE'"
112 test.after_completion(|db| {
113 // Ensure index has been removed after the migration is complete
118 FROM pg_catalog.pg_index
119 JOIN pg_catalog.pg_class ON pg_index.indexrelid = pg_class.oid
120 WHERE pg_class.relname = 'name_idx'
126 .map(|row| row.get(0))
129 assert_eq!(0, count, "expected index to not exist");
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