From 4bfb38abb236aad104e14750cd7eccd43a5fcb95 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon <pingou@pingoured.fr> Date: Jan 16 2017 21:32:33 +0000 Subject: Do not automatically update the last_updated or updated_on fields Turns out that there are a few cases where to adjust the data in the database and we do not need/want the user to know it changed. One classic example: merge status are stored in the database. When a pull-request is merged, the merge status of all the open pull-request is cleared. Before this commit, it meant that suddenly all the open pull-request had their updated_on field updated to the current time, while in practice nothing changed for this PR. Since we are manually updating this field where we want, in this commit we are removing the feature updating the data automatically. And bonus point, it turns out this does not need an alembic migration since this onupdate is not stored in the database itself, it is in fact a feature of SQLAlchemy. --- diff --git a/pagure/lib/model.py b/pagure/lib/model.py index 1fcc4df..34d4aff 100644 --- a/pagure/lib/model.py +++ b/pagure/lib/model.py @@ -685,8 +685,7 @@ class Issue(BASE): date_created = sa.Column(sa.DateTime, nullable=False, default=datetime.datetime.utcnow) last_updated = sa.Column(sa.DateTime, nullable=False, - default=datetime.datetime.utcnow, - onupdate=datetime.datetime.utcnow) + default=datetime.datetime.utcnow) closed_at = sa.Column(sa.DateTime, nullable=True) project = relation( @@ -1269,8 +1268,7 @@ class PullRequest(BASE): updated_on = sa.Column( sa.DateTime, nullable=False, - default=sa.func.now(), - onupdate=sa.func.now()) + default=datetime.datetime.utcnow) last_updated = sa.Column(sa.DateTime, nullable=False, default=datetime.datetime.utcnow,