From f4185f97fa543f9509ab45e6fc6c1225a8311489 Mon Sep 17 00:00:00 2001 From: SunnyQjm Date: Tue, 29 Oct 2019 19:44:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=95=B0=E6=8D=AE=E5=BA=93?= =?UTF-8?q?=E8=BF=81=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 76 ++-------------------- ormconfig.json => migration-ormconfig.json | 4 +- package.json | 3 +- src/app.module.ts | 23 +++---- 4 files changed, 18 insertions(+), 88 deletions(-) rename ormconfig.json => migration-ormconfig.json (73%) diff --git a/README.md b/README.md index a59ef92..adbdfb6 100644 --- a/README.md +++ b/README.md @@ -1,75 +1,7 @@ -

- Nest Logo -

+# sunny-blog-server -[travis-image]: https://api.travis-ci.org/nestjs/nest.svg?branch=master -[travis-url]: https://travis-ci.org/nestjs/nest -[linux-image]: https://img.shields.io/travis/nestjs/nest/master.svg?label=linux -[linux-url]: https://travis-ci.org/nestjs/nest - -

A progressive Node.js framework for building efficient and scalable server-side applications, heavily inspired by Angular.

-

-NPM Version -Package License -NPM Downloads -Travis -Linux -Coverage -Gitter -Backers on Open Collective -Sponsors on Open Collective - - -

- +> ## 数据库迁移 -## Description - -[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository. - -## Installation - -```bash -$ npm install +```shell script +npm run migration ``` - -## Running the app - -```bash -# development -$ npm run start - -# watch mode -$ npm run start:dev - -# production mode -$ npm run start:prod -``` - -## Test - -```bash -# unit tests -$ npm run test - -# e2e tests -$ npm run test:e2e - -# test coverage -$ npm run test:cov -``` - -## Support - -Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support). - -## Stay in touch - -- Author - [Kamil Myśliwiec](https://kamilmysliwiec.com) -- Website - [https://nestjs.com](https://nestjs.com/) -- Twitter - [@nestframework](https://twitter.com/nestframework) - -## License - - Nest is [MIT licensed](LICENSE). diff --git a/ormconfig.json b/migration-ormconfig.json similarity index 73% rename from ormconfig.json rename to migration-ormconfig.json index 0495ea2..56f3461 100644 --- a/ormconfig.json +++ b/migration-ormconfig.json @@ -3,10 +3,10 @@ "host": "localhost", "port": 3306, "username": "sunny-blog", - "password": "XkczhsZc3F5ZDhsi", + "password": "LXDW4RjtyYdGKh64", "database": "sunny-blog", "entities": ["src/**/*.entity{.ts,.js}"], - "migrations": ["src/migration/*.ts"], + "migrations": ["migration/*.ts"], "cli": { "migrationsDir": "migration" } diff --git a/package.json b/package.json index ac4d0c0..a129a76 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,8 @@ "test:watch": "jest --watch", "test:cov": "jest --coverage", "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", - "test:e2e": "jest --config ./test/jest-e2e.json" + "test:e2e": "jest --config ./test/jest-e2e.json", + "migration": "ts-node ./node_modules/typeorm/cli.js migration:generate -n update -f migration-ormconfig.json && ts-node ./node_modules/typeorm/cli.js migration:run -f migration-ormconfig.json" }, "dependencies": { "@nestjs/common": "^6.7.2", diff --git a/src/app.module.ts b/src/app.module.ts index fbd54ca..55d2baf 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -8,20 +8,17 @@ import { PostModule } from './post/post.module'; import { AdminModule } from './admin/admin.module'; @Module({ - imports: [TypeOrmModule.forRoot({ - type: 'mysql', - host: 'localhost', - port: 3306, - username: 'sunny-blog', - password: 'XkczhsZc3F5ZDhsi', - database: 'sunny-blog', - entities: [__dirname + '/**/*.entity{.ts,.js}'], - migrationsRun: true, - migrations: ['migration/*.ts'], - cli: { - migrationsDir: 'migration', + imports: [TypeOrmModule.forRoot( + { + type: 'mysql', + host: 'localhost', + port: 3306, + username: 'sunny-blog', + password: 'LXDW4RjtyYdGKh64', + database: 'sunny-blog', + entities: [__dirname + '/**/*.entity{.ts,.js}'], }, - }), UserModule, AuthModule, PostModule, AdminModule], + ), UserModule, AuthModule, PostModule, AdminModule], controllers: [AppController], providers: [AppService], })