4

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.

Huy Nguyen
  • 2,025
  • 3
  • 25
  • 37
ISONecroMAn
  • 1,460
  • 2
  • 16
  • 23
  • This question is too broad. It's going to require designing your database tables, your queries, and your code to support it. This isn't something that can be covered well in a couple paragraphs. You can't just find a full tutorial for everything on the internet. You're going to have to be able to piece your knowledge together to create larger solutions on your own. This is also a "gimme teh codez" question, so -1 as well. – jpmc26 Sep 03 '16 at 16:19
  • I didn't expect anyone givin me exactly the full code.But reasonable sized answers with or without code, as i asked a specific non existing question. Forget my example. The guide lines for making the 'Versioning with a History Table' in other SQL techs exists, but neither the flask-sqlalchemy docs or any other sources, including stack over flow , has got any answers regarding how to do it with Flask alchemy( Outsource i might be wrong). – ISONecroMAn Sep 03 '16 at 17:40
  • I included the simple example( completely fictional), so that people can explain better, on it. – ISONecroMAn Sep 03 '16 at 17:43
  • 3
    All i find is this http://docs.sqlalchemy.org/en/latest/orm/examples.html#versioning-objects i don't know what should i do with this.! – ISONecroMAn Sep 03 '16 at 18:03

0 Answers0