UNPKG

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
import 'reflect-metadata'; import { Entity, MikroORM, PrimaryKey, Property } from '@mikro-orm/sqlite'; import { remove } from 'fs-extra'; import { TEMP_DIR } from '../helpers'; @Entity({ tableName: 'user' }) class UserBefore { @PrimaryKey() id!: string; @Property() created: Date = new Date(); @Property() updated: Date = new Date(); @Property() deleted: Date = new Date(); } @Entity({ tableName: 'user' }) class UserAfter { @PrimaryKey() id!: string; @Property() createdAt: Date = new Date(); @Property() updatedAt: Date = new Date(); @Property() 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'); }); });