Debian Codegraph @

tests/db-migration-0-1-foreign-key-violation/t

raw
1 interimap_init
2 grep -Fx "database: Created mailbox INBOX" <"$STDERR" || error "INBOX missing from DB"
3
4 # empty table `mailboxes` and revert its schema to version 0
5 sqlite3 "$XDG_DATA_HOME/interimap/remote.db" <<-EOF
6 PRAGMA foreign_keys = OFF;
7 PRAGMA user_version = 0;
8 DROP TABLE mailboxes;
9 CREATE TABLE mailboxes (
10 idx INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
11 mailbox TEXT NOT NULL CHECK (mailbox != '') UNIQUE,
12 subscribed BOOLEAN NOT NULL
13 );
14 EOF
15
16 # now migration must fail due to broken referential integrity
17 ! interimap || error
18 grep -Fx "Upgrading database version from 0" <"$STDERR" || error "DB upgrade not attempted"
19 grep -Fx "database: ERROR: Broken referential integrity! Refusing to commit changes." <"$STDERR" || error "DB upgrade successful despite broken refint"
20
21 # vim: set filetype=bash :