How to properly configure db-migrate nodejs? Error in database.json

Asked

Viewed 174 times

0

I’m trying to use db-migrate but I’m getting the answer, when running db-migrate up, the mistake:

[ERROR] TypeError: Cannot read property '1' of null
   at Class.parseName (/usr/local/lib/node_modules/db-migrate/lib/skeleton.js:163:17)
   at Class.init (/usr/local/lib/node_modules/db-migrate/lib/migration.js:20:24)
   at Class.prototype.(anonymous function) [as init] (/usr/local/lib/node_modules/db-migrate/lib/class.js:46:26)
   at new Class (/usr/local/lib/node_modules/db-migrate/lib/class.js:59:17)
   at /usr/local/lib/node_modules/db-migrate/lib/migration.js:339:14
   at Array.map (<anonymous>)
   at /usr/local/lib/node_modules/db-migrate/lib/migration.js:338:35
   at FSReqWrap.oncomplete (fs.js:135:15)

the database.json file looks like this:

{

    "dev": {
        "driver": {"ENV": "DRIVER"},
        "user":  {"ENV": "USERDB"},
        "password":  {"ENV": "PASSWORDDB"},
        "host": {"ENV": "HOSTDB"},
        "database": {"ENV": "DATABASE"},
        "multipleStatements": true
    }
}

and the file . env contains the correct keys to access the database, in case DRIVER="mysql".

I tried to create Migrations with db-migrate create add-table-people --sql-file and fill in the . sql files and it didn’t work, also tried with db-migrate create add-table-people where the file contains the up function:

exports.up = function(db) {
    db.createTable("teste", {
        "id": {
            "type": "int",
            "primaryKey": true,
            "autoIncrement": true
        }
    });
};

I’m trying to follow this tutorial https://db-migrate.readthedocs.io/en/latest/

  • Hi @Paula. Did you find out what was causing this error? It’s happening the same here with me.

1 answer

0

I was also with this problem I ended up discovering the error. This will occur when the table migrations contains Rows that there is no corresponding Migration in the file system. Probably someone ran migrations in the same database you are trying to run up but the person does not committed her migrations or your local repository is not updated with the latest files.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.