Skip to content

datetime column showing changed on every schema:sync run #2333

@ktwbc

Description

@ktwbc

Issue type:

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

Database system/driver:

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

TypeORM version:

[ ] latest
[ ] @next
[ X] 0.2.6 (or put your version here)

Steps to reproduce or a small repository showing the problem:

  1. Create new entity file:
import { Entity, PrimaryGeneratedColumn, Column } from 'typeorm';


@Entity('test')
export class Test {

  @PrimaryGeneratedColumn()
  id: number;

  @Column({type: 'datetime', nullable: true, default: null})
  publish_date: Date;

}

  1. Run command schema:sync
    Initial run of command shows:
CREATE TABLE `test` (`id` int NOT NULL AUTO_INCREMENT, `publish_date` datetime NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB
  1. Confirm table has been created
  2. Run schema:sync again

Run will show an alter table erroneously (and will repeat on every run)

ALTER TABLE `test` CHANGE `publish_date` `publish_date` datetime NULL

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions