undeexcepturi
Version:
TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.
72 lines (52 loc) • 1.5 kB
text/typescript
import { Entity, MikroORM, PrimaryKey, Property } from '@mikro-orm/postgresql';
({
tableName: 'gh3339.Customer',
})
export class Customer1 {
({ fieldName: 'ID', type: 'number' })
id!: number;
()
customerName?: string;
}
({
tableName: 'gh3339.Customer',
})
export class Customer2 {
({ fieldName: 'ID', type: 'number' })
id!: number;
()
name?: string;
}
({
tableName: 'gh3339.Customer',
})
export class Customer3 {
({ fieldName: 'ID', type: 'number' })
id!: number;
()
c_name?: string;
}
describe('GH issue 3339', () => {
let orm: MikroORM;
beforeAll(async () => {
orm = await MikroORM.init({
dbName: `mikro_orm_test_gh_3339`,
schema: 'gh3339',
entities: [ Customer1 ],
});
await orm.schema.refreshDatabase();
});
afterAll(() => orm.close(true));
test('reference schema name when updating column names inside sql', async () => {
orm.getMetadata().reset('Customer1');
await orm.discoverEntity(Customer2);
const diff1 = await orm.schema.getUpdateSchemaSQL({ wrap: false });
expect(diff1).toContain('"gh3339"."Customer"');
await orm.schema.execute(diff1);
orm.getMetadata().reset('Customer2');
await orm.discoverEntity(Customer3);
const diff2 = await orm.schema.getUpdateSchemaSQL({ wrap: false });
expect(diff2).toContain('"gh3339"."Customer"');
await orm.schema.execute(diff2);
});
});