-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Closed
Labels
Description
Issue Description
Upon every startup, typeorm does the same alter. Over and over again. Same alter upon each startup:
ALTER TABLE `push_log` CHANGE `created` `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
Expected Behavior
No alters upon startup when its not necessary
Actual Behavior
Upon every startup, typeorm does the same alter. Over and over again. Same alter upon each startup.
removing @Index(["created"], { unique: false }) helped.
I could reproduce it both on heroku and my laptop ubuntu linux.
I don't know if it was introduced in typeorm only recently, or it was always there and I only noticed because production table grew big
and alter started taking minutes and I actually noticed it.
Steps to Reproduce
In previous to this fix commit It was reproduceable: BlueWallet/GroundControl@7b3b6f3
table that we have:
CREATE TABLE `push_log` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`token` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`success` tinyint(4) NOT NULL,
`created` timestamp NOT NULL DEFAULT current_timestamp(),
`os` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`response` text COLLATE utf8mb4_unicode_ci NOT NULL,
`payload` text COLLATE utf8mb4_unicode_ci NOT NULL,
PRIMARY KEY (`id`),
KEY `IDX_6df7a76e08bef8f18159126734` (`token`),
KEY `IDX_477ed76495567d90c759b416b4` (`created`)
) ENGINE=InnoDB AUTO_INCREMENT=1362892 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
entity definition:
import { Entity, PrimaryGeneratedColumn, Column, Index } from "typeorm";
@Entity()
@Index(["token"], { unique: false })
@Index(["created"], { unique: false })
export class PushLog {
@PrimaryGeneratedColumn()
id: number;
@Column()
token: string;
@Column()
os: string;
@Column("text")
payload: string;
@Column("text")
response: string;
@Column()
success: boolean;
@Column({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
created: Date;
}
My Environment
| Dependency | Version |
|---|---|
| Operating System | heroku. linux..? |
| Node.js version | v14.15.3 |
| Typescript version | 4.1.3 |
| TypeORM version | 0.2.30 |
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
Reactions are currently unavailable