-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for custom migration and seed templates (#145)
* Added support for custom migration and seed templates * Updated cli usage of the template flags * Updated ci * Added examples and updated readme * Updated changelog
- Loading branch information
1 parent
72c1d0d
commit 840a32b
Showing
11 changed files
with
178 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { | ||
AbstractClient, | ||
AbstractMigration, | ||
AbstractSeed, | ||
ClientPostgreSQL, | ||
} from "https://deno.land/x/nessie/mod.ts"; | ||
|
||
// This is a custom abstract migration class which can be used in the migration files | ||
export class CustomAbstractMigration<T extends AbstractClient<any> = any> | ||
extends AbstractMigration<T> { | ||
someHelperFunction() { | ||
console.log("Hey, I am available to all child classes!"); | ||
} | ||
} | ||
|
||
// I want to always use postres client in this class | ||
export class CustomAbstractSeed extends AbstractSeed<ClientPostgreSQL> { | ||
someHelperFunction() { | ||
console.log("Hey, I am available to all child classes!"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { ClientSQLite, NessieConfig } from "https://deno.land/x/nessie/mod.ts"; | ||
|
||
const config: NessieConfig = { | ||
client: new ClientSQLite("sqlite.db"), | ||
migrationTemplate: "./migration-template.ts", | ||
seedTemplate: "./seed-template.ts", | ||
}; | ||
|
||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { | ||
ClientPostgreSQL, | ||
Info, | ||
//As this is a custom template, I want to lock the nessie version to 2.0.0 | ||
} from "https://deno.land/x/[email protected]/mod.ts"; | ||
// I can import what I want to be used in this template | ||
import { CustomAbstractMigration } from "./abstract-classes-extended.ts"; | ||
|
||
export default class extends CustomAbstractMigration<ClientPostgreSQL> { | ||
async up({ dialect }: Info): Promise<void> { | ||
this.someHelperFunction(); | ||
} | ||
|
||
async down({ dialect }: Info): Promise<void> { | ||
// For this custom template, I do not want the down method to be predefined, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { | ||
ClientPostgreSQL, | ||
Info, | ||
//As this is a custom template, I want to lock the nessie version to 2.0.0 | ||
} from "https://deno.land/x/[email protected]/mod.ts"; | ||
// I can import what I want to be used in this template | ||
import { CustomAbstractSeed } from "./abstract-classes-extended.ts"; | ||
|
||
export default class extends CustomAbstractSeed { | ||
async run({ dialect }: Info): Promise<void> { | ||
this.someHelperFunction(); | ||
} | ||
} |
Oops, something went wrong.