-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
migrate:make fails with TypeScript #3003
Comments
I think this is probably related: #2998 |
Sounds like automatic knexfile resolving does not look for knexfile.ts, you can pass
I suppose client should look for knexfile.ts automatically though. |
I first noticed this with |
Also noticed today that |
We also use
knex migrate:make --knexfile knexfile.ts -x ts <your-migration-name>
knex migrate:latest --knexfile knexfile.ts
knex seed:make --knexfile knexfile.ts -x ts <your-seed-name>
knex seed:run --knexfile knexfile.ts The |
Any plans on fixing that? It's been hard to increase Knex adoption with this issue :/ |
@dgadelha Thanks for the reminder! I'll take a look today or tomorrow. |
@dgadelha 0.17.6 with fix for this was released. Unfortunately, fix for resolving extension from knexfile extension will only be available on master (starting on it right now). |
Please review! |
@kibertoad Just installed 0.17.6 and that behavior still happens, even when specifying ".ts" in the Knexfile. Are they separate bugs? |
@mathieumg Yes. See PR that I've created a couple of minutes ago and referenced from this issue :D |
@kibertoad I did! The description makes it sounds like that was rather for inferring the extension based on the same extension as the Knexfile, so I wasn't sure. |
|
Alright! Because 0.17.6 with |
Ah, you mean you have knexfile that has
in it? That one was fixed in a65a95b, you can already access it by locking your version at this commit (if you don't want to point at master directly). 0.18.0 is still quite ahead, but if depending on commits not an option for you, I could release next-1 instead. |
Hey, I've commented the PR, thanks a lot! |
@kibertoad Awesome, thanks for the precision! We can wait on 0.18, no stress. 😄 |
@kibertoad The commit you refer to only works if it is defined directly under module.exports = {
migrations: {
extension: 'ts';
}
} But the migrations object that defines where to put, and read from, migrations have to be defined under module.exports = {
[environment]: {
migrations: {
directory: './migrations';
}
} If I move the |
@ViggoV Thanks for the bug report! Will try to address this today. |
@ViggoV Can you try latest master and report back if it works correctly in your case now? |
Released in 0.18.0-next2 |
Sorry, I ended up switching to |
Hi i had the same problem. I solved requiring ts-node/register in my knexfile.ts like this `
} ` |
I don't know if you already solved the issue but in my case the solution was very simple. I just move the knexfile.js to the root of project. I installed the knex in directory "/backend" but for unknow reason the file moved to other directory. So I moved knexfile.js to "backend/knexfile.js" and works like a charm. I hope it will be useful for someone. |
Hi @moacirandretti , my knexfile.ts it's in the root project, but cli heroku
I installed this package ts-node in dev dependency |
I faced the same error. import dotenv from "dotenv";
import { Config } from "knex";
dotenv.config();
interface KnexConfig {
[name: string]: Config;
}
const knexConfig: KnexConfig = {
development: {
client: "pg",
connection: {
host: process.env.DB_HOST || "127.0.0.1",
user: process.env.DB_USERNAME || "postgres",
password: process.env.DB_PASSWRORD || "postgres",
database: process.env.DB_DEV_NAME || "done_list",
},
migrations: {
directory: "./migrations",
extension: "ts",
},
},
test: {
client: "pg",
connection: {
host: process.env.DB_HOST || "127.0.0.1",
user: process.env.DB_USERNAME || "postgres",
password: process.env.DB_PASSWRORD || "postgres",
database: process.env.DB_DEV_NAME || "done_list_test",
},
},
};
export { knexConfig }; when I run Typescript: 4.0.2 |
Environment
Knex version: 0.16.3 (Using TypeScript knexfile)
Database + version: PostgreSQL 10.5
OS: Windows 10 Pro 64 Bit
Bug
When running
knex migrate:make somename
, this is the output:This is the content of my
knexfile.ts
:Some additional details:
knex migrate:make somename
works if I change knexfile extension to.js
. (knex 0.16.3)knex migrate:make somename
works like it should with TypeScript knexfile when using knex 0.15.1 and@types/knex
0.15.1 package.The text was updated successfully, but these errors were encountered: