Skip to content

Commit

Permalink
feat: 添加迁移文件
Browse files Browse the repository at this point in the history
  • Loading branch information
LiuSongJiang committed Apr 26, 2019
1 parent a36b1b4 commit 2ff5dbb
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 55 deletions.
98 changes: 49 additions & 49 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
{
"name": "hapi-ts",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "supervisor -w build ./build/app.js",
"tslint": "tslint -c tslint.json src/**/*.ts",
"tsc": "tsc"
},
"author": "",
"keywords": [
"typescript",
"nodejs"
],
"license": "ISC",
"dependencies": {
"axios": "^0.18.0",
"boom": "^7.3.0",
"hapi": "^18.0.0",
"hapi-auth-jwt2": "^8.3.0",
"hapi-pagination": "^2.0.0",
"hapi-swagger": "^9.4.2",
"inert": "^5.1.3",
"joi": "^13.7.0",
"jsonwebtoken": "^8.5.1",
"lodash": "^4.17.11",
"mysql2": "^1.6.5",
"nconf": "^0.10.0",
"package": "^1.0.1",
"reflect-metadata": "^0.1.13",
"require-all": "^3.0.0",
"sequelize": "^5.2.13",
"sequelize-cli-typescript": "https://github.com/GreyHanky/sequelize-cli-typescript.git",
"sequelize-typescript": "^1.0.0-alpha.9",
"vision": "^5.4.4"
},
"devDependencies": {
"@types/bluebird": "^3.5.26",
"@types/node": "^11.13.0",
"@types/sequelize": "^4.27.46",
"@types/validator": "^10.11.0",
"babel-eslint": "^10.0.1",
"eslint": "^5.16.0",
"eslint-plugin-node": "^8.0.1",
"ts-loader": "^5.3.3",
"ts-node": "^8.0.3",
"tslint": "^5.15.0",
"typescript": "^3.4.2"
}
"name": "hapi-ts",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "supervisor -w build ./build/app.js",
"tslint": "tslint -c tslint.json src/**/*.ts",
"tsc": "tsc"
},
"author": "",
"keywords": [
"typescript",
"nodejs"
],
"license": "ISC",
"dependencies": {
"axios": "^0.18.0",
"boom": "^7.3.0",
"hapi": "^18.0.0",
"hapi-auth-jwt2": "^8.3.0",
"hapi-pagination": "^2.0.0",
"hapi-swagger": "^9.4.2",
"inert": "^5.1.3",
"joi": "^13.7.0",
"jsonwebtoken": "^8.5.1",
"lodash": "^4.17.11",
"mysql2": "^1.6.5",
"nconf": "^0.10.0",
"package": "^1.0.1",
"reflect-metadata": "^0.1.13",
"require-all": "^3.0.0",
"sequelize": "^5.2.13",
"sequelize-cli-typescript": "https://github.com/GreyHanky/sequelize-cli-typescript.git",
"sequelize-typescript": "^1.0.0-alpha.9",
"vision": "^5.4.4"
},
"devDependencies": {
"@types/bluebird": "^3.5.26",
"@types/node": "^11.13.0",
"@types/sequelize": "^4.27.46",
"@types/validator": "^10.11.0",
"babel-eslint": "^10.0.1",
"eslint": "^5.16.0",
"eslint-plugin-node": "^8.0.1",
"ts-loader": "^5.3.3",
"ts-node": "^8.0.3",
"tslint": "^5.15.0",
"typescript": "^3.4.2"
}
}
6 changes: 4 additions & 2 deletions src/db/migrations/20190403142735-create-users-table.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { QueryInterface } from "sequelize";

const tableName = "users";

export = {
up: (queryInterface: QueryInterface, Sequelize) =>
queryInterface.createTable("users", {
queryInterface.createTable(tableName, {
user_id: {
type: Sequelize.INTEGER,
autoIncrement: true,
Expand All @@ -16,5 +18,5 @@ export = {
created_at: Sequelize.DATE,
updated_at: Sequelize.DATE
}),
down: (queryInterface: QueryInterface) => queryInterface.dropTable("users")
down: (queryInterface: QueryInterface) => queryInterface.dropTable(tableName)
};
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import { QueryInterface } from "sequelize";

const tableName = "consumer";
export = {
up: (queryInterface: QueryInterface, Sequelize) =>
queryInterface.createTable("consumer", {
queryInterface.createTable(tableName, {
consumer_id: {
type: Sequelize.INTEGER,
autoIncrement: true,
primaryKey: true
},
user_id: Sequelize.INTEGER,
type: Sequelize.STRING
// amount:
type: Sequelize.STRING,
amount: Sequelize.DECIMAL
}),
down: (queryInterface: QueryInterface) => queryInterface.dropTable("consumer")
down: (queryInterface: QueryInterface) => queryInterface.dropTable(tableName)
};

0 comments on commit 2ff5dbb

Please sign in to comment.