-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Closed
Closed
Copy link
Labels
Description
Issue Description
Expected Behavior
I added a @UpdateDateColumn() and I generated a new Migration with this change. I think it should generate an ON UPDATE clause in the query to create this column. For example, a good result would be
await queryRunner.query("ALTER TABLE `operation` ADD `updatedDate` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)");Actual Behavior
The generated migration for the @UpdateDateColumn() is the same as the @CreateDateColumn(). However, I don't think it's good.
For example, here is the generated code in the up() method to create the @CreateDateColumn() and the @UpdateDateColumn():
await queryRunner.query("ALTER TABLE `operation` ADD `createdDate` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6)");
await queryRunner.query("ALTER TABLE `operation` ADD `updatedDate` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6)");Steps to Reproduce
- Add the folowing code to an existing entity:
@CreateDateColumn()
createdDate: Date;
@UpdateDateColumn()
updatedDate: Date;- Generate the migration for this change
- If you look the
up()method of the created migration, you should see the problem.
My Environment
| Dependency | Version |
|---|---|
| Operating System | Linux Debian 10 |
| Node.js version | v13.14.0 |
| Typescript version | v3.7.4 |
| TypeORM version | v0.2.28 |
Relevant Database Driver(s)
-
aurora-data-api -
aurora-data-api-pg -
better-sqlite3 -
cockroachdb -
cordova -
expo -
mongodb -
mysql -
nativescript -
oracle -
postgres -
react-native -
sap -
sqlite -
sqlite-abstract -
sqljs -
sqlserver
Are you willing to resolve this issue by submitting a Pull Request?
- Yes, I have the time, and I know how to start.
- Yes, I have the time, but I don't know how to start. I would need guidance.
- No, I don't have the time, although I believe I could do it if I had the time...
- No, I don't have the time and I wouldn't even know how to start.