Skip to content

Commit

Permalink
fixExampleBugs
Browse files Browse the repository at this point in the history
  • Loading branch information
mmRoshani committed Jul 25, 2022
1 parent 1380f5b commit 5306414
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 19 deletions.
5 changes: 5 additions & 0 deletions example/.env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
DATABASE_USER=postgres
DATABASE_PASS=root
DATABASE_NAME=STM
DATABASE_DIALECT=postgres
DATABASE_TIMEZONE=+03:30
12 changes: 6 additions & 6 deletions example/config/config.js → example/db/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ const path = require("path");
const inflection = require("inflection");

module.exports = {
username: process.env.SEQUELIZE_USERNAME,
password: process.env.SEQUELIZE_PASSWORD,
database: "test_migration2",
host: process.env.SEQUELIZE_HOST,
dialect: "mysql",
username: process.env.DATABASE_USER,
password: process.env.DATABASE_PASS,
database: process.env.DATABASE_NAME,
host: process.env.DATABASE_HOST,
dialect: process.env.DATABASE_DIALECT,
models: [path.join(process.cwd(), "models")],
modelMatch: (_filename, _member) => {
const filename = inflection.camelize(_filename.replace(".model", ""));
const member = _member;
return filename === member;
},
timezone: "+09:00",
timezone: process.env.DATABASE_TIMEZONE,
};
File renamed without changes.
File renamed without changes.
9 changes: 5 additions & 4 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
"practice": "ts-node -T -r tsconfig-paths/register practice.ts"
},
"dependencies": {
"typescript": "^4.3.4",
"sequelize": "^6.6.2",
"sequelize-typescript": "^2.1.0"
"typescript": "^4.3.5",
"sequelize": "^6.7.0",
"sequelize-cli": "^6.2.1",
"sequelize-typescript": "^2.1.1"
},
"devDependencies": {
"sequelize-cli": "^6.2.0",
"sequelize-cli": "^6.2.1",
"ts-node": "^10.0.0"
}
}
23 changes: 14 additions & 9 deletions example/practice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,27 @@ import { Sequelize } from "sequelize-typescript";
import * as path from "path";
import { Car } from "models/car.model";
import { CarBrand } from "models/car_brand.model";
import { Dialect } from "sequelize/types";

const bootstrap = async () => {
const sequelize: Sequelize = new Sequelize({
username: "kimjbstar",
password: "12091457",
database: "test_migration2",
host: "localhost",
dialect: "mysql",
username: process.env.DATABASE_USER,
password: process.env.DATABASE_PASS,
database: process.env.DATABASE_NAME,
host: process.env.DATABASE_HOST,
dialect: process.env.DATABASE_DIALECT as Dialect,
models: [CarBrand, Car],
timezone: "+09:00",
timezone: process.env.DATABASE_TIMEZONE,
logging: false,
});
try {
const result = await SequelizeTypescriptMigration.makeMigration(sequelize, {
outDir: path.join(__dirname, "./migrations"),
});
const result = await SequelizeTypescriptMigration.makeMigration(
sequelize[0],
{
outDir: path.join(__dirname, "./migrations"),
migrationName: Date.now.toString(),
}
);
console.log(result);
} catch (e) {
console.log(e);
Expand Down

0 comments on commit 5306414

Please sign in to comment.