Skip to content

Commit

Permalink
feat(migrate): Allow migration engine to log to stdout (#7896)
Browse files Browse the repository at this point in the history
* feat(migrate): Allow migration engine to log to stdout

As a first step, we only log what migrations are being applied.

See the corresponding engines PR at prisma/prisma-engines#2044

closes https://github.com/prisma/migrations-team/issues/241

* Update packages/migrate/src/MigrateEngine.ts

Co-authored-by: Joël <joel.galeran@gmail.com>
Co-authored-by: Joël Galeran <Jolg42@users.noreply.github.com>
  • Loading branch information
3 people committed Aug 2, 2021
1 parent 0229501 commit b3941af
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/migrate/src/MigrateEngine.ts
Expand Up @@ -275,6 +275,10 @@ export class MigrateEngine {
try {
const json: MigrateEngineLogLine = JSON.parse(data)

if (json.fields?.migrate_action === 'log') {
console.info(json.fields.message)
}

this.messages.push(json.fields.message)

if (json.level === 'ERROR') {
Expand Down
2 changes: 2 additions & 0 deletions packages/sdk/src/migrateEngineCommands.ts
Expand Up @@ -38,6 +38,8 @@ type LogLevel = 'INFO' | 'ERROR' | 'DEBUG' | 'WARN'
interface LogFields {
message: string
git_hash?: string
/// Hint from the engine to the CLI to log this line.
migrate_action?: 'log'
// Only for ERROR level messages
is_panic?: boolean
error_code?: string
Expand Down

0 comments on commit b3941af

Please sign in to comment.