Skip to content

Commit

Permalink
v2.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
evantahler committed Feb 10, 2020
1 parent 6b10b8f commit 7983f6a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion __tests__/integration.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Process, env, specHelper } from "actionhero";
import { Process, env } from "actionhero";
import { User } from "../src/models/User";
import { Post } from "../src/models/Post";

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "ah-sequelize-plugin",
"license": "Apache-2.0",
"description": "Use Sequelize in ActionHero",
"version": "2.0.1",
"version": "2.0.2",
"homepage": "http://actionherojs.com",
"repository": {
"type": "git",
Expand Down
17 changes: 11 additions & 6 deletions src/initializers/sequelize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,26 @@ export class SequelizeInitializer extends Initializer {
async start() {
api.sequelize = new Sequelize(config.sequelize);
await this.test();
await this.migrate();
await this.migrate(config.sequelize.autoMigrate);
}

async stop() {
await api.sequelize.close();
}

async migrate() {
this.importMigrationsFromDirectory(config.sequelize.migrations);
for (const umzug of this.umzug) {
await umzug.up();
async migrate(toMigrate: boolean) {
if (toMigrate) {
log("running sequelize migrations", "debug");
this.importMigrationsFromDirectory(config.sequelize.migrations);
for (const umzug of this.umzug) {
await umzug.up();
}
} else {
log("skipping sequelize migrations", "debug");
}
}

importMigrationsFromDirectory(dir) {
importMigrationsFromDirectory(dir: string) {
(Array.isArray(dir) ? dir : [dir]).forEach(dir => {
const umzug = new Umzug({
storage: "sequelize",
Expand Down

0 comments on commit 7983f6a

Please sign in to comment.