EOSIO / EOSIO/demux-js-postgres

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

Open
#78 9 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
11
Forks
8
PR merge metrics
No merged PRs in 30d

Description

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](https://user-images.githubusercontent.com/2347572/63527305-bccd1080-c4f8-11e9-88d2-75eb644240fd.png)

```
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. (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. (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
);
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.