on main help sign in
Update order of actions complex column move example
commit0a3715fe746e7bf36312411f71ece180da4cc72a authorfabianlindfors <fabian@flapplabs.se> dateSun 21 Jan 2024, 23:05 (3 years ago) parent4c316ae
2 files changed+12−12
README.md+11−11 tests/complex.rs+1−1
README.md+11−11
@@ -627,17 +627,6 @@ The `up` and `down` options available when creating tables, adding columns and r
627627_Example: move `email` column from `users` to `profiles` table_
628628
629629```toml
630−[[actions]]
631−type = "remove_column"
632−table = "users"
633−column = "email"
634−
635− # When `profiles` is changed in the new schema, we write the email address back to the removed column
636− [actions.down]
637− table = "profiles"
638− value = "profiles.email"
639− where = "users.id = profiles.user_id"
640−
641630[[actions]]
642631type = "add_column"
643632table = "profiles"
@@ -652,6 +641,17 @@ table = "profiles"
652641 table = "users"
653642 value = "users.email"
654643 where = "profiles.user_id = users.id"
644+
645+[[actions]]
646+type = "remove_column"
647+table = "users"
648+column = "email"
649+
650+ # When `profiles` is changed in the new schema, we write the email address back to the removed column
651+ [actions.down]
652+ table = "profiles"
653+ value = "profiles.email"
654+ where = "users.id = profiles.user_id"
655655```
656656
657657_Example: turn a 1:N relationship between `users` and `accounts` into N:M and change the format of the associated `role`_
tests/complex.rs+1−1
@@ -52,7 +52,7 @@ fn move_column_between_tables() {
5252 nullable = false
5353
5454 # When `users` is updated in the old schema, we write the email value to `profiles`
55− # When `profiles` is updated in the old schema, we touch the equivalent `users` row to update it
55+ # When `profiles` is updated in the old schema, the equivalent `users.email` will also be updated
5656 [actions.up]
5757 table = "users"
5858 value = "users.email"