Fixes modified_date columns in PostgreSQL database by copying the original value from a backup instance. Useful when Alembic data migration unexpectedly changes the modified_date column.
Table of Contents
pip install lifelike-fix-modified-date
Or from source:
pip install git+https://github.com/SBRG/lifelike-fix-modified-date.git
$ lifelike-fix-modified-date --help
lifelike-fix-modified-date
Fixes all modified_date columns in a database to match the values in a backup database.
This is useful when a database migration updates modified_date column in a table unintentionally.
Usage:
lifelike-fix-modified-date (-h | --help | --version)
lifelike-fix-modified-date stats --database=<uri>
lifelike-fix-modified-date fix <bad_modified_date> --database=<uri> --backup-database=<uri>
[--table=<table>] [--ignore-count-mismatch]
Generic options:
-h --help Show this screen.
--version Show version.
--database=<uri> Postgres URI of the target database.
Fix options:
--backup-database=<uri> Postgres URI of the backup (source) database.
--table=<table> Table name to fix. [default: files]
--ignore-coount-mismatch Ignore row count mismatch between backup source and target databases
(e.g. if there are deleted rows since the backup was taken).
Examples:
lifelike-fix-modified-date stats --database=postgres://user:pass@localhost:5432/db
lifelike-fix-modified-date fix "2022-08-03 18:21:49.498104" --database=postgres://user:pass@host:5432/db --backup-database=postgres://user:pass@backup-host:5432/db
Get modified_date column stats for all tables
$ python -m lifelike_fix_modified_date stats --database postgresql://user:pass@host:port/db
Fix the modified_date column in the files
table to match the backup database.
$ python -m lifelike_fix_modified_date \
fix "2022-08-03 18:21:49.498104" --table files \
--database postgresql://user:pass@database-host:port/db \
--backup-database postgresql://user:pass@backup-host:port/db
lifelike-fix-modified-date
is distributed under the terms of the MIT license.