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
Last week I had an issue with a new migration, that would not run with all previous migration at once on an empty database. Though it was running, if it was presented a database that had some of the previous migrations being run on. I managed to enclose the problem down to three migrations which I condensed to the code below which will reproduce the error. I also found out that I can prevent the error by calling queryRunner.getTable(tableName); right before the failing migration.
Issue Description
Expected Behavior
I expect the migration below to succeed without uncommenting await queryRunner.getTable(tableName); in the migration 2 of the code below.
Actual Behavior
The migration fails.
Migration "foo1663574872076" failed, error: constraint.clone is not a function
query: ROLLBACK
Error during migration run:
TypeError: constraint.clone is not a function
at .../node_modules/typeorm/src/schema-builder/table/Table.ts:163:66
at Array.map (<anonymous>)
at Table.clone (.../node_modules/typeorm/src/schema-builder/table/Table.ts:163:35)
at PostgresQueryRunner.addColumn (.../node_modules/typeorm/src/driver/postgres/PostgresQueryRunner.ts:876:35)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async foo1663574872076.up (.../apps/app-metadata-adapter/src/migrations/1663574872076-foo.js:32:5)
at async MigrationExecutor.executePendingMigrations (.../node_modules/src/migration/MigrationExecutor.ts:262:17)
at async DataSource.runMigrations (.../node_modules/src/data-source/DataSource.ts:377:13)
at async Object.handler (.../node_modules/src/commands/MigrationRunCommand.ts:67:13)
Steps to Reproduce
run the migration below on a (postgres) database and it will fail
uncomment the line await queryRunner.getTable(tableName); of migration 2 and the whole migration will succeed
const{ Table, TableColumn }=require('typeorm');consttableName='foo';constunique={name: 'myUnique',columnNames: ['bar']};constquxName='qux';module.exports=classfoo1663574872076{asyncup(queryRunner){// migration 1awaitqueryRunner.createTable(newTable({name: tableName,columns: [{name: 'id',type: 'integer',isPrimary: true,isGenerated: true,},{name: 'bar',type: 'varchar',isNullable: true},],}));// migration 2awaitqueryRunner.createUniqueConstraint(tableName,unique);// await queryRunner.getTable(tableName); // <- remove comment and migration 3 will succeed// migration 3 -> fails, error: constraint.clone is not a functionawaitqueryRunner.addColumn(tableName,newTableColumn({name: quxName,type: 'varchar',isNullable: true,}));}asyncdown(queryRunner){awaitqueryRunner.dropColumn(tableName,quxName);awaitqueryRunner.dropUniqueConstraint(tableName,unique.name);awaitqueryRunner.dropTable(tableName);}};
My Environment
Dependency
Version
Operating System
Linux
Node.js version
v16.17.0
Typescript version
4.7.3
TypeORM version
0.3.6
nx/nrwl
14.4.3
nestjs
8.1.2
Additional Context
Relevant Database Driver(s)
DB Type
Reproducible
aurora-mysql
no
aurora-postgres
no
better-sqlite3
no
cockroachdb
no
cordova
no
expo
no
mongodb
no
mysql
no
nativescript
no
oracle
no
postgres
yes
react-native
no
sap
no
spanner
no
sqlite
no
sqlite-abstract
no
sqljs
no
sqlserver
no
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, but I can support (using donations) development.
✅ No, I don’t have the time and I’m okay to wait for the community / maintainers to resolve this issue.
The text was updated successfully, but these errors were encountered:
Last week I had an issue with a new migration, that would not run with all previous migration at once on an empty database. Though it was running, if it was presented a database that had some of the previous migrations being run on. I managed to enclose the problem down to three migrations which I condensed to the code below which will reproduce the error. I also found out that I can prevent the error by calling
queryRunner.getTable(tableName);
right before the failing migration.Issue Description
Expected Behavior
I expect the migration below to succeed without uncommenting
await queryRunner.getTable(tableName);
in the migration 2 of the code below.Actual Behavior
The migration fails.
Steps to Reproduce
await queryRunner.getTable(tableName);
of migration 2 and the whole migration will succeedMy Environment
Additional Context
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?
The text was updated successfully, but these errors were encountered: