Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using NestJS and TypeOrm, the tables are not being created automatically after I run the NestJS application

Using a postgres DB, I am able to connect to the database, however even when following tutorials step-by-step, after creating the user.entity.ts file (code below), nothing in the database changes.

postgres/typeorm are installed correctly as far as im aware with latest versions.

import { Entity, PrimaryGeneratedColumn, Column } from 'typeorm'

@Entity()
export class Users {

    @PrimaryGeneratedColumn('uuid')
    id: number

    @Column({
        length: 50
    })
    firstName: string;
}

Here is the ormconfig.json

{
    "type": "postgres",
    "host": "localhost",
    "port": "5432",
    "username": "postgres",
    "password": "pw",
    "database": "metabook",
    "synchronise": true,
    "logging": true,
    "entities": ["./dist/**/*.entity{.ts,.js}"]
}

It should be adding the 'users' table with 2 columns (id and firstName). In the console, logging, as its set to true in the ormconfig.json, should show the sql queries being run to create the table, but nothing happens other than the success of running the application (output below).

Output

Expected output from tutorial video

Anyone know if I am missing something?

like image 320
Ryan Marshall Avatar asked Sep 15 '25 15:09

Ryan Marshall


1 Answers

As @Jay McDoniel pointed out, synchronise should be spelt with a z not an s... (synchronize)

like image 154
Ryan Marshall Avatar answered Sep 18 '25 09:09

Ryan Marshall