synchronize: true
in your connection options:name
column option:NOW()
?default
column option supports a function. If you are passing a function which returns a string, it will use that string as a default value without escaping it. For example:@JoinColumn
and @JoinTable
?one-to-one
relation. Let's say we have two entities: User
and Photo
:@JoinColumn
which is incorrect. Why? Because to make a real relation, we need to create a column in the database. We need to create a column userId
in photo
or photoId
in user
. But which column should be created - userId
or photoId
? TypeORM cannot decide for you. To make a decision, you must use @JoinColumn
on one of the sides. If you put @JoinColumn
in Photo
then a column called userId
will be created in the photo
table. If you put @JoinColumn
in User
then a column called photoId
will be created in the user
table. The side with @JoinColumn
will be called the "owner side of the relationship". The other side of the relation, without @JoinColumn
, is called the "inverse (non-owner) side of relationship".@ManyToMany
relation. You use @JoinTable
to show the owner side of the relation.@ManyToOne
or @OneToMany
relations, @JoinColumn
is not necessary because both decorators are different, and the table where you put the @ManyToOne
decorator will have the relational column.@JoinColumn
and @JoinTable
decorators can also be used to specify additional join column / junction table settings, like join column name or junction table name.outDir
compiler option, don't forget to copy assets and resources your app is using into the output directory. Otherwise, make sure to setup correct paths to those assets.Post
entity and rename it to Blog
, you no longer have Post.ts
in your project. However, Post.js
is left inside the output directory. Now, when TypeORM reads entities from your output directory, it sees two entities - Post
and Blog
. This may be a source of bugs. That's why when you remove and move entities with outDir
enabled, it's strongly recommended to remove your output directory and recompile the project again.ts
entities inside your connection options:outDir
compiler option to prevent this issue.entry
configuration for the migration files only.mode: 'production'
, files are optimized by default which includes mangling your code in order to minimize file sizes. This breaks the migrations because TypeORM relies on their names to determine which has already been executed. You may disable minimization completely by adding:UglifyJsPlugin
, you can tell it to not change class or function names like so:ormconfig
file, the transpiled migration files are included: