cli
cli copied to clipboard
SQLite relative path doesn't work with URI
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.
Does anybody care at all?
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
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.
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)