Skip to content

Add support for output from migration scripts #12

@nmummau

Description

@nmummau

It would be nice if output from sql migration scripts would be printed in the terminal.
For example, currently when running postgrator 0020 the terminal output is as follows.

[7:01:25 PM] version of database is: 10
[7:01:25 PM] migrating up to 20
[7:01:25 PM] verifying checksum of migration 0010.do.create role admin_users.sql
[7:01:25 PM] running 0020.do.create role app_users.sql

In my 0020.do.create role app_users.sql file I have SELECT output like this (examples):

SELECT CONCAT(
   to_char(current_timestamp, '[HH12:MI:SS PM]'), ' Beginning script'
);
--do work
--do more work
SELECT CONCAT(
   to_char(current_timestamp, '[HH12:MI:SS PM]'), ' Beginning transaction'
);
--commit the transaction
SELECT CONCAT(
   to_char(current_timestamp, '[HH12:MI:SS PM]'), 'Transaction complete - 50 rows inserted'
);

It would be great if I could get this as output in the terminal (emphasizing the hypothetical last 3 lines):

[7:01:25 PM] version of database is: 10
[7:01:25 PM] migrating up to 20
[7:01:25 PM] verifying checksum of migration 0010.do.create role admin_users.sql
[7:01:25 PM] running 0020.do.create role app_users.sql
[7:01:25 PM] Beginning script
[7:01:28 PM] Beginning transaction
[7:02:06 PM] Transaction complete - 50 rows inserted

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions