Preparing to migrate to SQLLite

Not tested.