Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infinite same ALTERs upon startup (mysql, ver 0.2.30) #7381

Closed
1 of 17 tasks
Overtorment opened this issue Feb 16, 2021 · 0 comments · Fixed by #7517
Closed
1 of 17 tasks

Infinite same ALTERs upon startup (mysql, ver 0.2.30) #7381

Overtorment opened this issue Feb 16, 2021 · 0 comments · Fixed by #7517

Comments

@Overtorment
Copy link

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
AlexMesser added a commit that referenced this issue Mar 31, 2021
AlexMesser added a commit that referenced this issue Apr 1, 2021
…ies during synchronization (#7517)

* fix #3991

* fix #3991

* improved test for #2737;
fixed remaining issues in #2737;

* fix #6412

* added test for #4281 and #4658

* fixed `NOW()` function usage in MySQL/MariaDB;
fixed precision in datetime functions for MySQL/MariaDB;
improved #3991 test for MySQL/MariaDB;

* added test for #2333

* added test for #7381

* added "remove" operation check in #4658 test

* fixed precision in datetime functions for PostgreSQl;
improved #3991 test for PostgreSQl;

* improved #3991 test for CockroachDB;

* improved #3991 test for Sqlite;

* improved #3991 test for Oracle and SQLServer;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant