Skip to content

Timestamp Migration continuously sets CURRENT_TIMESTAMP default value #6579

@lucaslacerdacl

Description

@lucaslacerdacl

Issue type:

[ ] bug report
[ ] feature request
[X] documentation issue

Database system/driver:

[ ] cordova
[ ] mongodb
[ ] mssql
[ ] mysql / mariadb
[ ] oracle
[X] postgres
[ ] cockroachdb
[ ] sqlite
[ ] sqljs
[ ] react-native
[ ] expo

TypeORM version:

[X] latest
[ ] @next
[ ] 0.x.x (or put your version here)

Steps to reproduce or a small repository showing the problem:

Hey folks, how u guys doing?

Well, I wondering why Typeorm create ALTER TABLE script everytime a run migration generate.
Here's an example:

I have a prop call createdAt.

  @Column('timestamp', { nullable: false, default: () => 'CURRENT_TIMESTAMP' })
  createdAt: Date;

When I run the first migration the result is:
CREATE TABLE "name" ("createdAt" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP)

When I change any thing, or even generate a migration without changes, I get this:
ALTER TABLE "name" ALTER COLUMN "createdAt" SET DEFAULT CURRENT_TIMESTAMP

Why I receive this ALTER TABLE, and how a configure to not create this script.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions