Skip to content

Commit

Permalink
Merge pull request #55 from halvardssm/v1/rc2
Browse files Browse the repository at this point in the history
Release candidate 2
  • Loading branch information
halvardssm authored Jun 7, 2020
2 parents 71c5f85 + 340ba35 commit 3ed7e38
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion examples/migration-third-party.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ export const up: Migration = ({ dialect }) => { // The dialect depends on which
});
};

export const down: Migration = () => {
export const down: Migration = ({ dialect }) => {
return Dex({ client: dialect }).schema.dropTable("test");
};
8 changes: 4 additions & 4 deletions examples/migration-using-connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { Migration } from "https://deno.land/x/nessie/mod.ts";
import { Schema } from "https://deno.land/x/nessie/qb.ts";

export const up: Migration<Schema> = async ({ queryBuilder, connection }) => {
const hasTable = await connection(queryBuilder!.hasTable("basics"));
const hasTable = await connection(queryBuilder.hasTable("basics"));
const hasColumn = await connection(
queryBuilder!.hasColumn("basics", "col_1"),
queryBuilder.hasColumn("basics", "col_1"),
);

// Using Postgres as an example, will differ between clients
Expand All @@ -16,9 +16,9 @@ export const up: Migration<Schema> = async ({ queryBuilder, connection }) => {
});
}

return queryBuilder;
return queryBuilder.query;
};

export const down: Migration = ({ dialect, queryBuilder }) => {
export const down: Migration<Schema> = ({ dialect, queryBuilder }) => {
return queryBuilder.drop("basics");
};
6 changes: 3 additions & 3 deletions types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ export type DBDialects = "pg" | "mysql" | "sqlite3";
/** Exposed object in migration files. available in `up`/`down` methods.
* queryBuilder is available when passing `exposeQueryBuilder: true` to the config file.
*/
export type Info<T = any> = {
export type Info<T = undefined> = {
dialect: DBDialects;
connection: QueryHandler;
queryBuilder?: T;
queryBuilder: T;
};

/** `up`/`down` methods in migration files. */
export type Migration<T = any> = (
export type Migration<T = undefined> = (
info: Info<T>,
) => string | string[] | Promise<string | string[]>;
/** `run` method in seed files. */
Expand Down

0 comments on commit 3ed7e38

Please sign in to comment.