Skip to content

Commit

Permalink
fix TypeScript migration stub after 0.95.0 changes (#4366)
Browse files Browse the repository at this point in the history
* fix TypeScript migration stub after 0.95.0 changes

Release 0.95.0 changed how types have to be imported when using TypeScript. This PR fixes the migration stub so new migrations are created correctly.

* Add test for Knex.AlterTableBuilder

Co-authored-by: Igor Savin <iselwin@gmail.com>
  • Loading branch information
santialbo and kibertoad committed Mar 11, 2021
1 parent 5d1f479 commit 548471d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/migrations/migrate/stub/ts.stub
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Knex } from "knex";

<% if (d.tableName) { %>
export async function up(knex: Knex): Promise<Knex.SchemaBuilder> {
return knex.schema.createTable("<%= d.tableName %>", (t: Knex.AlterTableBuilder) => {
return knex.schema.createTable("<%= d.tableName %>", (t) => {
t.increments();
t.timestamps();
});
Expand Down
2 changes: 2 additions & 0 deletions test-tsd/types.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ expectType<any>(knexCjs({}));
// eslint-disable-next-line
expectType<any>(knexCjsNamed({}));

knex({}).schema.createTable("table", (t: Knex.AlterTableBuilder) => {})

const knexInstance = knexDefault(clientConfig);

// ToDo remove this copy-pasted type after we can export it as a named properly
Expand Down

0 comments on commit 548471d

Please sign in to comment.