Skip to content

TypeError: Invalid query format when massive & pg-promise match demux-js-postgres module #78

@jasonbert

Description

@jasonbert

I'm receiving the TypeError: Invalid query format. error when my init migration is run. The setup prior to that has created tables in Postgres, so it's definitely able to do some queries.

image

PS C:\Work\bb\git\enterprise.demux> node src/index.js                                                                                                                                                                                                    
-- Starting Demux --

[ { migrations: [ [Migration] ], sequenceName: 'init' } ]
{"name":"demux","hostname":"localhost","pid":23216,"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.
    at MassiveActionHandler.<anonymous> (C:\\Work\\bb\\git\\enterprise.demux\\node_modules\\demux-postgres\\dist\\MassiveActionHandler.js:97:23)
	TypeError: Invalid query format.
    at Database.$query (C:\\Work\\bb\\git\\enterprise.demux\\node_modules\\pg-promise\\lib\\query.js:104:21)
    at Database.<anonymous> (C:\\Work\\bb\\git\\enterprise.demux\\node_modules\\pg-promise\\lib\\query.js:259:23)
    at config.$npm.connect.pool.then.db (C:\\Work\\bb\\git\\enterprise.demux\\node_modules\\pg-promise\\lib\\database.js:326:42)
    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-08-22T15:05:10.796Z","v":0}
{"name":"demux","hostname":"localhost","pid":23216,"level":30,"msg":"Indexing unexpectedly paused due to an error.","time":"2019-08-22T15:05:10.797Z","v":0}

index.js

console.log("");
console.log("-- Starting Demux --")
console.log("");

const massive = require('massive')
const { BaseActionWatcher } = require("demux")
const { MassiveActionHandler } = require("demux-postgres")
const { NodeosActionReader } = require("demux-eos")

const handlerVersions = require("./handlerVersions")
const migrationSequences = require("./migrationSequences")

console.log(migrationSequences);

const dbConfig = {
    host: '127.0.0.1',
    port: 5432,
    database: 'enterprise',
    user: 'postgres',
    password: 'docker'
}

massive(dbConfig).then((db) => {
    const actionReader = new NodeosActionReader("http://localhost:8888", 0)
    const actionHandler = new MassiveActionHandler(
        handlerVersions,
        db,
        "public",
        migrationSequences
    )
    const actionWatcher = new BaseActionWatcher(actionReader, actionHandler, 500)
    actionWatcher.watch()
})

migrationSequences/index.js

const { Migration } = require('demux-postgres')

const createTables = new Migration(
    "createTables", // name
    "public", // schema
    "migrationSequences/createTables.sql", // SQL file
)
  
module.exports = [{
    migrations: [createTables],
    sequenceName: "init"
}]

migrationSequences/createTables.sql

CREATE TABLE IF NOT EXISTS "${schema^}"."match_type" (
    "id" CHAR(64) PRIMARY KEY,
    "type" VARCHAR NOT NULL,
    "max_oppoonents" INTEGER NOT NULL
);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions