cli icon indicating copy to clipboard operation
cli copied to clipboard

SQLite relative path doesn't work with URI

Open jooohny opened this issue 4 years ago • 4 comments

I'm working on Windows. I have my config file in root\db-migration\config.js. Where root is my abstract working directory. And it contains the following:

module.exports = {
    development: {
        storage: 'private/db/db.sqlite3',
        dialect: 'sqlite',
    },
};

When I migrate everything is ok and database file appears in correct directory: root\private\db\db.sqlite3. Once I'm trying to configure it as URI (and that's exactly what I need) like:

module.exports = {
    development: {
        url: 'sqlite:private/db/db.sqlite3',
    },
};

.. and I expect sequelize-cli to do exactly the same thing. But it creates directories in my disk : D:\db\db.sqlite3. Or in D:\private\db\db.sqlite3 if I specify url: 'sqlite:./private/db/db.sqlite3'. I've also tried some deviations with file: or something - I'm only getting errors or facing the same result.

jooohny avatar Sep 08 '21 22:09 jooohny

Does anybody care at all?

jooohny avatar Sep 13 '21 10:09 jooohny

Hi! Thanks for making an issue about this. This is due to the way that the URL is parsed for sqlite, see snippet below. Is there a reason that using storage and dialect instead of the URL is not possible? https://github.com/sequelize/cli/blob/fcea7a36b66906ccf3e488bb5b1eb9648f1f5287/src/helpers/config-helper.js#L199-L217

WikiRik avatar Nov 11 '21 10:11 WikiRik

Hello. The reason is pretty clear: to use environment variable to keep DB connection string and set its value depending on environment in one place.

jooohny avatar Nov 12 '21 21:11 jooohny

Sounds fair, I will qualify this as a bug since you should be able to do this. A workaround is possible, but feel free to make a PR to solve this issue (or anyone else that reads this issue)

WikiRik avatar Nov 12 '21 22:11 WikiRik