| 1 |
# create the mailboxes from the database |
| 2 |
doveadm -u "local" mailbox create --no-userdb-lookup "a.b1.c1" "a.b1.c2" "a.b2.c" "a2" |
| 3 |
doveadm -u "remote" mailbox create --no-userdb-lookup "a.b1.c1" "a.b1.c2" "a.b2.c" "a2" |
| 4 |
|
| 5 |
# import an existing non-migrated database |
| 6 |
sqlite3 "$XDG_DATA_HOME/interimap/remote.db" <"$TESTDIR/before.sql" || error "Couldn't import DB" |
| 7 |
|
| 8 |
# migrate |
| 9 |
interimap || error "Couldn't upgrade DB" |
| 10 |
|
| 11 |
grep -Fx "Upgrading database version from 0" <"$STDERR" || error "Couldn't upgrade DB" |
| 12 |
check_mailboxes_status "a.b1.c1" "a.b1.c2" "a.b2.c" "a2" |
| 13 |
|
| 14 |
# verify that the new schema is as expected |
| 15 |
sqlite3 "$XDG_DATA_HOME/interimap/remote.db" >"$TMPDIR/dump.sql" <<-EOF |
| 16 |
DELETE FROM local; |
| 17 |
DELETE FROM remote; |
| 18 |
.dump |
| 19 |
EOF |
| 20 |
|
| 21 |
# re-import and dump the expected dump to work around SQLite format |
| 22 |
# differences across versions |
| 23 |
sqlite3 "$XDG_DATA_HOME/interimap/remote2.db" <"$TESTDIR/after.sql" |
| 24 |
sqlite3 "$XDG_DATA_HOME/interimap/remote2.db" >"$TMPDIR/dump-expected.sql" <<-EOF |
| 25 |
.dump |
| 26 |
EOF |
| 27 |
|
| 28 |
# XXX need 'user_version' PRAGMA in the dump for future migrations |
| 29 |
# http://sqlite.1065341.n5.nabble.com/dump-command-and-user-version-td101228.html |
| 30 |
diff -u --label="a/dump.sql" --label="b/dump.sql" \ |
| 31 |
"$TMPDIR/dump-expected.sql" "$TMPDIR/dump.sql" \ |
| 32 |
|| error "DB dumps differ" |
| 33 |
|
| 34 |
# vim: set filetype=bash : |