PRAGMA cipher_migrate problem

Hi everyone!
I’ve studied couple of threads related to migration issues on Android similar to this one Upgrading to SQLCipher 4 but still facing some problems.
The app is using SqlCipher for Android v3.5.7 together with OrmLite. I need to switch to Room Persistence Library but to do that I need to update version of SqlCipher to latest one since it’s compatible with Room.

So, current implementation (with v3.5.7) has custom settings described in the hook’s postkey

database.rawExecSQL("PRAGMA cipher_page_size = 2048;");
database.rawExecSQL("PRAGMA cipher = 'aes-128-cfb';");
database.rawExecSQL("PRAGMA kdf_iter = 20000;");

As was suggested the proper way to do it is custom export migration. So, after those three line from the hook I’m calling this function to migrate my db.

fun migrateToCipher4(context: Context, database: SQLiteDatabase) {
    val newDbName = "<my-new-db-name>"
    val newDbFile = context.getDatabasePath("$newDbName.db")
    val newDbPath = newDbFile.absolutePath
    val newDbKey = "<my-new-db-password>"
    val newDbVersion = 1

    val dbHelper = DatabaseHelper4(context, "$newDbName.db", null, newDbVersion, newDbKey)
    val db = dbHelper.getWritableDatabase(newDbKey)
    db.close()
    dbHelper.close()
    
    database.rawExecSQL("ATTACH DATABASE '$newDbPath' AS $newDbName KEY '$newDbKey';")
    database.rawExecSQL("SELECT sqlcipher_export('$newDbName');")
    database.rawExecSQL("DETACH DATABASE $newDbName;")
}

But it fails during execution of ATTACH query with ‘file is not a database’ error.
net.sqlcipher.database.SQLiteException: file is not a database
at net.sqlcipher.database.SQLiteDatabase.native_rawExecSQL(Native Method)

Besides, new db file is created and I can open it with DB browser for SQLite with default SqlCipher4 settings. But it’s empty since error happens before export query runs.

Any ideas what could’ve been missing? Thanks in advance.