diff --git a/src/packages/migrate/src/__tests__/MigrateDev.test.ts b/src/packages/migrate/src/__tests__/MigrateDev.test.ts index 8b597a3e8676..bc5682e50079 100644 --- a/src/packages/migrate/src/__tests__/MigrateDev.test.ts +++ b/src/packages/migrate/src/__tests__/MigrateDev.test.ts @@ -343,7 +343,7 @@ describe('sqlite', () => { it('transition-db-push-migrate (prompt reset yes)', async () => { ctx.fixture('transition-db-push-migrate') - prompt.inject(['first', 'y']) + prompt.inject(['y', 'first']) const result = MigrateDev.new().parse(['--preview-feature']) @@ -356,14 +356,9 @@ describe('sqlite', () => { Datasource "my_db": SQLite database "dev.db" at "file:dev.db" + Drift detected: Your database schema is not in sync with your migration history. - The following migration was created from new schema changes: - migrations/ - └─ 20201231000000_first/ - └─ migration.sql - - Drift detected: Your database schema is not in sync with your migration history. The following migration(s) have been created and applied from new schema changes: @@ -381,7 +376,7 @@ describe('sqlite', () => { ctx.fixture('transition-db-push-migrate') const mockExit = jest.spyOn(process, 'exit').mockImplementation() - prompt.inject(['first', new Error()]) + prompt.inject([new Error(), 'first']) const result = MigrateDev.new().parse(['--preview-feature']) @@ -392,13 +387,6 @@ describe('sqlite', () => { Datasource "my_db": SQLite database "dev.db" at "file:dev.db" - - The following migration was created from new schema changes: - - migrations/ - └─ 20201231000000_first/ - └─ migration.sql - Drift detected: Your database schema is not in sync with your migration history. @@ -446,7 +434,7 @@ describe('sqlite', () => { ctx.fixture('edited-and-draft') fs.remove('prisma/migrations/20201117144659_test') - prompt.inject(['y']) + prompt.inject(['mymigration']) const result = MigrateDev.new().parse(['--preview-feature']) @@ -476,7 +464,7 @@ describe('sqlite', () => { The following migration(s) have been created and applied from new schema changes: migrations/ - └─ 20201231000000_/ + └─ 20201231000000_mymigration/ └─ migration.sql `) @@ -645,11 +633,11 @@ describe('sqlite', () => { await expect(result).rejects.toMatchInlineSnapshot(` - ⚠️ We found changes that cannot be executed: + ⚠️ We found changes that cannot be executed: - • Step 0 Made the column \`fullname\` on table \`Blog\` required, but there are 1 existing NULL values. + • Step 0 Made the column \`fullname\` on table \`Blog\` required, but there are 1 existing NULL values. - `) + `) expect(ctx.mocked['console.info'].mock.calls.join('\n')) .toMatchInlineSnapshot(` Prisma schema loaded from prisma/schema.prisma @@ -688,10 +676,10 @@ describe('sqlite', () => { expect(ctx.mocked['console.log'].mock.calls.join('\n')) .toMatchInlineSnapshot(` - ⚠️ There will be data loss when applying the migration: + ⚠️ There will be data loss when applying the migration: - • You are about to drop the \`Blog\` table, which is not empty (2 rows). - `) + • You are about to drop the \`Blog\` table, which is not empty (2 rows). + `) expect(ctx.mocked['console.error'].mock.calls).toMatchSnapshot() }) @@ -713,10 +701,10 @@ describe('sqlite', () => { expect(ctx.mocked['console.log'].mock.calls.join('\n')) .toMatchInlineSnapshot(` - ⚠️ There will be data loss when applying the migration: + ⚠️ There will be data loss when applying the migration: - • You are about to drop the \`Blog\` table, which is not empty (2 rows). - `) + • You are about to drop the \`Blog\` table, which is not empty (2 rows). + `) expect(ctx.mocked['console.error'].mock.calls).toMatchSnapshot() }) }) diff --git a/src/packages/migrate/src/commands/MigrateDev.ts b/src/packages/migrate/src/commands/MigrateDev.ts index 89a3299943a4..0107f1db93df 100644 --- a/src/packages/migrate/src/commands/MigrateDev.ts +++ b/src/packages/migrate/src/commands/MigrateDev.ts @@ -40,9 +40,7 @@ export class MigrateDev implements Command { } private static help = format(` -${ - process.platform === 'win32' ? '' : chalk.bold('🏋️ ') -}Create a migration from changes in Prisma schema, apply it to the database, trigger generators (e.g. Prisma Client) +Create a migration from changes in Prisma schema, apply it to the database, trigger generators (e.g. Prisma Client) ${chalk.bold.yellow('WARNING')} ${chalk.bold( `Prisma's migration functionality is currently in Preview (${link( @@ -149,7 +147,7 @@ ${chalk.bold('Examples')} debug({ diagnoseResult }) let isResetNeeded = false - let isResetNeededAfterCreate = false + const isResetNeededAfterCreate = false let migrationIdsFromDatabaseIsBehind: string[] = [] let migrationIdsFromAfterReset: string[] = [] @@ -238,17 +236,13 @@ ${ ${diagnoseResult.drift.error.message}`, ) } else if (diagnoseResult.drift.diagnostic === 'driftDetected') { - if (diagnoseResult.hasMigrationsTable === false) { - isResetNeededAfterCreate = true - } else { - // we could try to fix the drift in the future - console.info() // empty line - console.info( - 'Drift detected: Your database schema is not in sync with your migration history.', - ) - console.info() // empty line - isResetNeeded = true - } + // we could try to fix the drift in the future + console.info() // empty line + console.info( + 'Drift detected: Your database schema is not in sync with your migration history.', + ) + console.info() // empty line + isResetNeeded = true } }