# No such collation sequence: PHONEBOOK during PRAGMA cipher\_migrate

**URL:** https://discuss.zetetic.net/t/no-such-collation-sequence-phonebook-during-pragma-cipher-migrate/779
**Category:** Issues
**Created:** [September 24, 2015, 9:25pm UTC](https://discuss.zetetic.net/t/no-such-collation-sequence-phonebook-during-pragma-cipher-migrate/779 "2015-09-24T21:25:07Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![mrpc\_cambodia](https://avatars.discourse-cdn.com/v4/letter/m/a8b319/32.png) [@mrpc\_cambodia](https://discuss.zetetic.net/u/mrpc_cambodia)
#### Post date: [September 24, 2015, 9:25pm UTC](https://discuss.zetetic.net/t/no-such-collation-sequence-phonebook-during-pragma-cipher-migrate/779/1 "2015-09-24T21:25:07Z")

</div>

Android app running an older version of SQLCipher. Call PRAGMA cipher\_migrate inside of SQLiteDatabaseHook to upgrade sqlcipher from v2 to v3.3.1.

Migration failed. The error message shows:  
sqlite returned: error code = 1, msg = no such collation sequence: PHONEBOOK  
I/Database(27940): sqlite returned: error code = 1, msg = statement aborts at 2: [SELECT sqlcipher\_export(‘migrate’);] no such collation sequence: PHONEBOOK

So it looks like the migration doesn’t recognize a collation named “PHONEBOOK”. But on a fresh install of the app with the collation explicitly specified for one of a table column, there is no error, which is weird.

---

<div class="post-metadata">

### Author: ![developernotes](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/developernotes/32/1309_2.png) [@developernotes](https://discuss.zetetic.net/u/developernotes)
#### Post date: [September 24, 2015, 9:43pm UTC](https://discuss.zetetic.net/t/no-such-collation-sequence-phonebook-during-pragma-cipher-migrate/779/2 "2015-09-24T21:43:20Z")

</div>

Hello @mrpc_cambodia

Would you be able to provide a reproducible test case in the SQLCipher for Android [test suite](https://github.com/sqlcipher/sqlcipher-android-tests)? We would be glad to take a look further into this. Thanks!

---

<div class="post-metadata">

### Author: ![mrpc\_cambodia](https://avatars.discourse-cdn.com/v4/letter/m/a8b319/32.png) [@mrpc\_cambodia](https://discuss.zetetic.net/u/mrpc_cambodia)
#### Post date: [September 25, 2015, 2:21pm UTC](https://discuss.zetetic.net/t/no-such-collation-sequence-phonebook-during-pragma-cipher-migrate/779/3 "2015-09-25T14:21:11Z")

</div>

So it happens during the upgrade of SQLCipher from a version less than 3 to v3.3.1. Start with an Android app and create a table:

```
CREATE TABLE table1 (_id INTEGER PRIMARY KEY AUTOINCREMENT, contact_no TEXT COLLATE PHONEBOOK)

```

The important thing here is to have PHONEBOOK collation assigned to one of the column. Now update SQLCipher binary, both jar and \*.so to v3.3.1. Update constructor of a subclass of SQLiteOpenHelper to include SQLiteDatabaseHook to handle the upgrade.

```
new SQLiteDatabaseHook() {
            @Override
            public void preKey(SQLiteDatabase sqLiteDatabase) {

            }

            @Override
            public void postKey(SQLiteDatabase sqLiteDatabase) {
                    sqLiteDatabase.rawQuery("PRAGMA cipher_migrate;",
                            new String[]{});
             }
}

```

Rebuild and install on top of the existing app. Launch the app and logcat will show the message below:

> sqlite returned: error code = 1, msg = no such collation sequence: PHONEBOOK  
> I/Database(27940): sqlite returned: error code = 1, msg = statement aborts at 2: [SELECT sqlcipher\_export(‘migrate’);] no such collation sequence: PHONEBOOK

In spite of the error message, any API call to access the database works fine. After a device reboot or force close of the app through app manager, the app will crash as soon as there is a call to access the database.
