while trying to run demux, I am getting an error.

The proper initialization has not occurred. Failed to migrate the postgres database.

The full error code is this:

{"name":"demux","hostname":"dev-eosio-1","pid":27981,"level":50,"err":{"message":"The proper initialization has not occurred. Failed to migrate the postgres database.","name":"NotInitializedError","stack":"NotInitializedError: The proper initialization has not occurred. Failed to migrate the postgres database.\n at MassiveActionHandler. (/home/nodeos2/demux/node_modules/demux-postgres/dist/MassiveActionHandler.js:103:22)\nTypeError: Invalid query format.\n at Database.$query (/home/nodeos2/demux/node_modules/massive/node_modules/pg-promise/lib/query.js:99:21)\n at Database. (/home/nodeos2/demux/node_modules/massive/node_modules/pg-promise/lib/query.js:259:23)\n at config.$npm.connect.pool.then.db (/home/nodeos2/demux/node_modules/massive/node_modules/pg-promise/lib/database.js:326:42)\n at process._tickCallback (internal/process/next_tick.js:68:7)"},"msg":"The proper initialization has not occurred. Failed to migrate the postgres database.","time":"2019-09-05T02:45:19.290Z","v":0} 
{"name":"demux","hostname":"dev-eosio-1","pid":27981,"level":30,"msg":"Indexing unexpectedly paused due to an error.","time":"2019-09-05T02:45:19.291Z","v":0}

After debugging through the node modules, I got a Promise { }, in Migration.js when calling pgp.none(this.upQueryFile) in the up(pgp) function.

The demux file I am running looks like this,

const { BaseActionWatcher } = require("demux")
const { MongoActionReader } = require("demux-eos")
const { MassiveActionHandler } = require("demux-postgres")
const { Migration } = require("demux-postgres")
const massive = require("massive")

// See https://eosio.github.io/demux-js/ for info on Handler Versions, Updaters, and Effects
// const handlerVersions = require("./handlerVersions") // Import your handler versions
const handlerVersions = [
        versionName: 'v1',
        deferUntilIrreversible: true,

// See "Migrations" section above
//const migrationSequences = require("./migrationSequences")

const createTodoTable = new Migration(
  "table", // name
  "schema", // schema
  "create_todo_table.sql" // SQL file

const migrationSequences = [{
  migrations: [createTodoTable],
  sequenceName: "init"


// See https://dmfay.github.io/massive-js/connecting.html for info on massive configuration
const dbConfig = {
  host: '',
  port: 5432,
  database: 'postgres',
  user: 'user',
  password: 'pass'

massive(dbConfig).then((db) => {
 console.log("logging this",migrationSequences);
    const actionHandler = new MassiveActionHandler(
    console.log("logging this",migrationSequences);
  const actionReader = new MongoActionReader({
    startAtBlock: 1234,              // startAtBlock: the first block relevant to our application
    onlyIrreversible: false,         // onlyIrreversible: whether or not to only process irreversible blocks
    dbName: "EOS2",                   // name of the database
    mongoEndpoint: "mongodb://user:[email protected]:27017/EOS2",    // mongoEndpoint: the url of the mongodb instance
  const actionWatcher = new BaseActionWatcher(actionReader, actionHandler, 500)
//async function migrateDatabase(db, payload) {
//  await db.migrate(payload.sequenceName)}

What is the reason for this error?

1 Answer 1


This issue is caused by using different version of pg-promise. QueryFile class from different version of pg-promise are incompatible. (vitaly-t/pg-promise#393)

demux-postgres depends on [email protected] and [email protected], but demux-eos depends on massive@^5.7.5, so installed massive on root of node_modules and massive on which demux-postgres depends will be different:

├┬[email protected]
│└─[email protected]
├┬[email protected]
│└┬[email protected]
│ └─[email protected]

Refer to https://github.com/EOSIO/demux-js-postgres/issues/67.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.