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.
62 lines (43 loc) • 1.2 kB
text/typescript
import 'reflect-metadata';
import { Entity, MikroORM, PrimaryKey, Property } from '@mikro-orm/sqlite';
import { remove } from 'fs-extra';
import { TEMP_DIR } from '../helpers';
({ tableName: 'user' })
class UserBefore {
()
id!: string;
()
created: Date = new Date();
()
updated: Date = new Date();
()
deleted: Date = new Date();
}
({ tableName: 'user' })
class UserAfter {
()
id!: string;
()
createdAt: Date = new Date();
()
updatedAt: Date = new Date();
()
deletedAt: Date = new Date();
}
describe('GH issue 1262', () => {
async function createAndRunMigration(entities: any[]) {
const db = await MikroORM.init({
entities,
dbName: TEMP_DIR + '/gh_1262.db',
});
await db.getSchemaGenerator().updateSchema();
await db.close();
}
test('renaming multiple columns at once', async () => {
await remove(TEMP_DIR + '/gh_1262.db');
await createAndRunMigration([UserBefore]);
// Simulates adding `profile` to the User entity
await createAndRunMigration([UserAfter]);
await remove(TEMP_DIR + '/gh_1262.db');
});
});