Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Including TypeORM migration in monorepo application #13106

Closed
6 of 15 tasks
asijoumi opened this issue Jan 28, 2024 · 1 comment
Closed
6 of 15 tasks

Including TypeORM migration in monorepo application #13106

asijoumi opened this issue Jan 28, 2024 · 1 comment
Labels
needs triage This issue has not been looked into

Comments

@asijoumi
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

Hi !

I have an issue using NestJS + TypeORM with migration.

I use NestJS as a monorepo. I have my public api, batch for scheduled process. And I have 2 libs : config and database.

In database, there are the entities and the migrations. When I want to start the API, the entities are "compiled" into the dist folder, but not the migration.

PS : webpack is not used here.

With npm run build I have :

Capture d’écran 2024-01-28 à 14 37 06

But, when I run npm run build database :

Capture d’écran 2024-01-28 à 14 38 26

I don't understand why the migration are compiled with database but not with the api ..

Minimum reproduction code

https://github.com/asijoumi/nest-issue-typeorm

Steps to reproduce

  1. npm run build
  2. npm run build database

Expected behavior

We should have migration .js files in dist folder.

Package

  • I don't know. Or some 3rd-party package
  • @nestjs/common
  • @nestjs/core
  • @nestjs/microservices
  • @nestjs/platform-express
  • @nestjs/platform-fastify
  • @nestjs/platform-socket.io
  • @nestjs/platform-ws
  • @nestjs/testing
  • @nestjs/websockets
  • Other (see below)

Other package

@nestjs/typeorm

NestJS version

10.0.0

Packages versions

{
  "name": "app",
  "version": "0.0.1",
  "description": "",
  "author": "",
  "private": true,
  "license": "UNLICENSED",
  "scripts": {
    "build": "nest build",
    "format": "prettier --write \"apps/**/*.ts\" \"libs/**/*.ts\"",
    "start": "nest start",
    "start:dev": "nest start --watch",
    "start:debug": "nest start --debug --watch",
    "start:prod": "node dist/apps/app/main",
    "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
    "test": "jest",
    "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 ./apps/app/test/jest-e2e.json",
    "migration:generate": "typeorm-ts-node-commonjs -d ./datasource.ts migration:generate ./libs/database/src/migrations/$npm_config_name",
    "migration:create": "typeorm-ts-node-commonjs -d ./datasource.ts migration:create ./libs/database/src/migrations/$npm_config_name",
    "migration:revert": "typeorm-ts-node-commonjs -d ./datasource.ts migration:revert"
  },
  "dependencies": {
    "@nestjs/common": "^10.0.0",
    "@nestjs/core": "^10.0.0",
    "@nestjs/mapped-types": "*",
    "@nestjs/platform-express": "^10.0.0",
    "@nestjs/typeorm": "^10.0.1",
    "reflect-metadata": "^0.1.13",
    "rxjs": "^7.8.1",
    "sqlite3": "^5.1.7",
    "typeorm": "^0.3.20"
  },
  "devDependencies": {
    "@nestjs/cli": "^10.0.0",
    "@nestjs/schematics": "^10.0.0",
    "@nestjs/testing": "^10.0.0",
    "@types/express": "^4.17.17",
    "@types/jest": "^29.5.2",
    "@types/node": "^20.3.1",
    "@types/supertest": "^2.0.12",
    "@typescript-eslint/eslint-plugin": "^6.0.0",
    "@typescript-eslint/parser": "^6.0.0",
    "eslint": "^8.42.0",
    "eslint-config-prettier": "^9.0.0",
    "eslint-plugin-prettier": "^5.0.0",
    "jest": "^29.5.0",
    "prettier": "^3.0.0",
    "source-map-support": "^0.5.21",
    "supertest": "^6.3.3",
    "ts-jest": "^29.1.0",
    "ts-loader": "^9.4.3",
    "ts-node": "^10.9.1",
    "tsconfig-paths": "^4.2.0",
    "typescript": "^5.1.3"
  },
  "jest": {
    "moduleFileExtensions": [
      "js",
      "json",
      "ts"
    ],
    "rootDir": ".",
    "testRegex": ".*\\.spec\\.ts$",
    "transform": {
      "^.+\\.(t|j)s$": "ts-jest"
    },
    "collectCoverageFrom": [
      "**/*.(t|j)s"
    ],
    "coverageDirectory": "./coverage",
    "testEnvironment": "node",
    "roots": [
      "<rootDir>/apps/",
      "<rootDir>/libs/"
    ],
    "moduleNameMapper": {
      "^@app/database(|/.*)$": "<rootDir>/libs/database/src/$1"
    }
  }
}

Node.js version

18.19.0

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

@asijoumi asijoumi added the needs triage This issue has not been looked into label Jan 28, 2024
@kamilmysliwiec
Copy link
Member

Thank you for taking the time to submit your report! From the looks of it, this could be better discussed on our Discord. If you haven't already, please join here and send a new post in the #⁠ 🐈 nestjs-help forum. Make sure to include a link to this issue, so you don't need to write it all again. We have a large community of helpful members, who will assist you in getting this to work.

@nestjs nestjs locked and limited conversation to collaborators Jan 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs triage This issue has not been looked into
Projects
None yet
Development

No branches or pull requests

2 participants