close cursors when querying (PRAGMA); simplified hasMigrationsTable