My models are made of flask-sqlalchemy on top of postgresql. I want to keep track of changes made my models.
I have a employees table:
class Employee(db.Model):
__tablename__ = 'employees'
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(60))
job_title = db.Column(db.String(60))
job_type = db.Column(db.String(60)) # teaching, IT, manager,
job_location = db.Column(db.String(60))
salary = db.Column(db.Numeric(15,2))
The salary of particular title of employees are increased from 30k to 35k at dec 2014
, and to 40k at jan 2016
.
And in some another part of my application say while calculating the revenue and balance sheet, the above employees.salary
is used in the formula. So I should be able to use old salary 30k for any calculation involving dates before dec 2014
, and 35k after that, up to jan 2016
. Any detailed answer with codes related to this example I have is much appreciated, thank you.
I've been searching for how to do this, everywhere with no luck.