Can't create columns in Postgre using ormconfig (NestJS)

Hi.
When I’m trying to deploy my NestJS project with connected postgre, columns are not created automatically.

This is Dockerfile:

FROM node:lts-alpine3.15

EXPOSE ${PORT}

WORKDIR /home/app/

RUN mkdir -p ./dist
RUN mkdir -p ./uploads
RUN mkdir -p ./logs

COPY migrations ./migrations
COPY typings ./typings
COPY src ./src

COPY package*.json tsconfig.json tsconfig.build.json ./

RUN npm ci
RUN npm run build

This is app.module part:

TypeOrmModule.forRoot({
      ...ormconfig,
      entities: [`${__dirname}/resources/**/**.entity{.ts,.js}`],
      migrations: [`${__dirname}/migrations/*.ts`],
    }),

And migrations file looks like this:

export class newTables1653159327291 implements MigrationInterface {
    name = 'newTables1653159327291'

    public async up(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`CREATE TABLE "columns" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "title" character varying NOT NULL, "order" integer NOT NULL, "boardId" uuid, CONSTRAINT "PK_4ac339ccbbfed1dcd96812abbd5" PRIMARY KEY ("id"))`);

Also when I try to build project using: nest build && npm run typeorm:migration, I have an error:

Error during migration run:

Error: Debug Failure. False expression: Non-string value passed to `ts.resolveTypeReferenceDirective`, likely by a wrapping package working with an outdated `resolveTypeReferenceDirectives` signature. This is probably not a problem in TS itself.

Sorry, I’m not good at backend part.

Hi there :slight_smile:

Googling the error: “Non-string value passed to ts.resolveTypeReferenceDirective” seems to indicate a version error.

Check out: ts node - False expression: Non-string value passed to ts.resolveTypeReferenceDirective in typescript - Stack Overflow for possible fixes.

So you could try to update your packages and/or node version. Render defaults to 14 but you can specify which version you want to run. Docs here: Specifying a Node Version | Render

I updated everything.
Now there are no errors, but the deployment just fails.
The last message in logs is

Pushing image to registry...
DONE

Hi there,

If your Dockerfile from your first message is complete, then the last thing it does is just run npm run build.

You’ll need a command to start a service, e.g.

CMD ["node", "server.js"]

Or whatever your starting point is.

Kind regards

Alan

Start command is specified in the settings. I thought that was enough.

I solved it somehow.
Just started migration manually.
Dropped docker and used node engine.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.