Skip to content

Issue with schema creation in 0.3.16 #10090

Closed
@N-Andronopoulos

Description

@N-Andronopoulos

Issue description

Syncronise: true messes up stuff after first run (tries to recreate db and fails)

Expected Behavior

To work after restarts.
Should be obvious, aka not to recreate the schema since nothing's changed.

Note: I think should happen in migrations as well....

Actual Behavior

query: ALTER TABLE orders ADD id varchar(36) NOT NULL PRIMARY KEY
query failed: ALTER TABLE orders ADD id varchar(36) NOT NULL PRIMARY KEY
error: Error: Duplicate entry '' for key 'orders.PRIMARY'
query: ROLLBACK
[Nest] 651697 - 05/30/2023, 11:04:50 AM ERROR [TypeOrmModule] Unable to connect to the database. Retrying (3)...
QueryFailedError: Duplicate entry '' for key 'orders.PRIMARY'

Steps to reproduce

See sample project.
But in general start app with synchronize: true and restart it.
(It also happens when you start the app with sync: true an then try doing a migration, see migrations/ on sample repo)

My Environment

Dependency Version
Operating System linux / win
Node.js version v18.16.0
Typescript version ^5.0.0
TypeORM version 0.3.16

Additional Context

====> Sample Project

Relevant Database Driver(s)

  • aurora-mysql
    aurora-postgres
    better-sqlite3
    cockroachdb
    cordova
    expo
    mongodb
    mysql
    nativescript
    oracle
    postgres
    react-native
    sap
    spanner
    sqlite
    sqlite-abstract
    sqljs
    sqlserver

Are you willing to resolve this issue by submitting a Pull Request?

Yes, I have the time, but I don't know how to start. I would need guidance.

Activity

N-Andronopoulos

N-Andronopoulos commented on May 30, 2023

@N-Andronopoulos
Author

I think there a fix for it maybe? If it is please close this one :)
#10041

peter-rybar

peter-rybar commented on Jun 8, 2023

@peter-rybar

Still no fix? It is a critical issue!
Seems like TypeORM deal breaker.

Mateozmaldonado17

Mateozmaldonado17 commented on Jun 9, 2023

@Mateozmaldonado17

Omg, i had this issue for long time, so i was thinking that was something wrong with my code

peter-rybar

peter-rybar commented on Jun 11, 2023

@peter-rybar

OK guys, no fix still? Really?

slyk

slyk commented on Jun 12, 2023

@slyk

OK guys, no fix still? Really?

For me this helps right now (I got UUID generated in code, but maybe even without it it would work)

  //@PrimaryGeneratedColumn('uuid')
  @PrimaryColumn({type:"varchar", generated:"uuid",length:36})
  uuid?: string;

12 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

      Issue with schema creation in 0.3.16 · Issue #10090 · typeorm/typeorm