Project

breathing

0.0
Low commit activity in last 3 years
Audit logging for database
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 3.9
>= 0

Runtime

 Project Readme

breathing

Audit logging for database. Logging mechanism using database triggers to store the old and new row states in JSON column types.

Install

gem install breathing

Usage

Install

Just run the following command.

% DATABASE_URL="mysql2://user:pass@host:port/database" breathing install
or
% DATABASE_URL="postgres://user:pass@host:port/database" breathing install
  • Create table change_logs
  • Create triggers
    • change_logs_insert_{table_name}
    • change_logs_update_{table_name}
    • change_logs_delete_{table_name}

Uninstall

Cleanup command.

% DATABASE_URL="mysql2://user:pass@host:port/database" breathing uninstall
  • Drop table change_logs
  • Drop triggers
    • change_logs_insert_{table_name}
    • change_logs_update_{table_name}
    • change_logs_delete_{table_name}

Export

% DATABASE_URL="mysql2://user:pass@host:port/database" breathing export
  • Output file breathing.xlsx

out

% DATABASE_URL="mysql2://user:pass@host:port/database" breathing out --table users --id 1
+----------------+------------------------+--------+----+-----+------+----------------------------+----------------------------+
|                                                            users                                                             |
+----------------+------------------------+--------+----+-----+------+----------------------------+----------------------------+
| change_logs.id | change_logs.created_at | action | id | age | name | created_at                 | updated_at                 |
+----------------+------------------------+--------+----+-----+------+----------------------------+----------------------------+
| 1              | 2020-12-18 22:43:32    | INSERT | 10  | 20  | a    | 2020-12-18 13:43:32.316923 | 2020-12-18 13:43:32.316923 |
| 2              | 2020-12-18 22:43:32    | UPDATE | 10  | 21  | a    | 2020-12-18 13:43:32.316923 | 2020-12-18 13:43:32.319706 |
| 3              | 2020-12-18 22:43:32    | DELETE | 10  | 21  | a    | 2020-12-18 13:43:32.316923 | 2020-12-18 13:43:32.319706 |
+----------------+------------------------+--------+----+-----+------+----------------------------+----------------------------+

tail

% DATABASE_URL="mysql2://user:pass@host:port/database" breathing tail --table users --id 1

Compatibility

  • Ruby 3.0.0+
  • MySQL 5.7.0+
  • PostgreSQL 8.0+

Copyright

Copyright (c) 2020 Akira Kusumoto. See MIT-LICENSE file for further details.