You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Changing the length of a timestamptz property results in an incorrect down migration.
I encountered this when preparing for v6, since the migration for both up and down were essentially identical, so a rollback wouldn't work. I think it would be a good idea to fix this bug before releasing v6, since this will be a common migration people will perform.
Reproduction
exportclassUser{
@PrimaryKey({columnType: 'uuid',defaultRaw: 'gen_random_uuid()'})id: string=uuid();
@Property({defaultRaw: 'NOW()',length: 2,// change this to 3 and create the migration})createdAt: Date=newDate();}
Create the migration:
yarn mikro-orm migration:create --name test
Results in:
exportclassMigration20231226222133_testextendsMigration{asyncup(): Promise<void>{this.addSql('alter table "user" alter column "created_at" type timestamptz(3) using ("created_at"::timestamptz(3));');}asyncdown(): Promise<void>{this.addSql('alter table "user" alter column "created_at" type timestamptz using ("created_at"::timestamptz);');}}
The down migration should have timestamptz(2) instead of just timestamptz.
Describe the bug
Changing the
length
of atimestamptz
property results in an incorrectdown
migration.I encountered this when preparing for v6, since the migration for both
up
anddown
were essentially identical, so a rollback wouldn't work. I think it would be a good idea to fix this bug before releasing v6, since this will be a common migration people will perform.Reproduction
Create the migration:
yarn mikro-orm migration:create --name test
Results in:
The
down
migration should havetimestamptz(2)
instead of justtimestamptz
.What driver are you using?
@mikro-orm/postgresql
MikroORM version
5.9.6
Node.js version
Node 18.18.2, TypeScript 5.3.3
Operating system
macOS 14.2.1
Validations
The text was updated successfully, but these errors were encountered: