docker run -p 5432:5432 --name some-postgres -e POSTGRES_PASSWORD=test -d postgres:12.1
- clone repository
- install yarn v1, https://classic.yarnpkg.com/lang/en/
- run
yarn install - edit
ormconfig.jsonand change your database configuration (e.g. username/password/database, you can also change a database type, but don't forget to install specific database drivers) - run
yarn dev - enjoy!
ref: https://typeorm.io/#/migrations
typeorm migration:create and typeorm migration:generate will create .ts files. The migration:run and migration:revert commands only work on .js files.
yarn typeorm migration:generate -n PostRefactoring- or
yarn typeorm migration:create+ fill the generated .ts byself
- or
yarn typeorm migration:run
-
Create empty migrations,
yarn migration_create -n PostRefactoringthen fill the generated .ts byself` -
yarn build -
yarn deploy_typeorm migration:run
Difficult to only use tsc to auto-generate migrations, need ts-node since the generated files are ts files
tslib 1.11.2/1.13.0 works
ref: typeorm/typeorm#6054
yarn startonly works for"entities": ["src/entity/*.js"]"entities": ["src/entity/*.{js,ts}"]is needed for ts-node usage.
ref:
- typeorm/typeorm#1327
- typeorm/typeorm#2882
- nestjs/nest#4283
- https://stackoverflow.com/questions/59435293/typeorm-entity-in-nestjs-cannot-use-import-statement-outside-a-module
- https://stackoverflow.com/questions/59727358/typeorm-dont-use-ormconfig-json-file
no.4 gives a hint to solve ts-node and tsc conflict issue, try to prepare 2 settings, ref: https://github.com/typeorm/typeorm/blob/master/docs/using-ormconfig.md