db-api-review: no oslo code uses created_at/updated_at fields

Bug #1119702 reported by Mark McLoughlin
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
oslo-incubator
Fix Released
Low
Zhongyue Luo

Bug Description

See https://review.openstack.org/17471

It looks like these fields:

  class ModelBase(object):
      ...
      created_at = Column(DateTime, default=timeutils.utcnow)
      updated_at = Column(DateTime, onupdate=timeutils.utcnow)

aren't actually set by any code in Oslo. Does it make sense to move these to an optional base class? Does it make sense to add common code for updating them?

Zhongyue Luo (zyluo)
Changed in oslo:
assignee: nobody → Zhongyue Luo (zyluo)
Revision history for this message
Zhongyue Luo (zyluo) wrote :

I'll take a shot at this.
It seems not all projects are using those fields and in fact some do not wish to update the updated_at field automatically.
In order to put oslo.db code in all projects I think created_at and updated_at should be in a DatetimeMixin (I'm not sure this is the perfect name) class.
Maybe there should be a DatetimeMixin and a OnUpdateDatetimeMixin?
What would be a good name for these mixins? suggestions?

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to oslo-incubator (master)

Fix proposed to branch: master
Review: https://review.openstack.org/26576

Changed in oslo:
status: Confirmed → In Progress
Revision history for this message
Zhongyue Luo (zyluo) wrote :
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to oslo-incubator (master)

Reviewed: https://review.openstack.org/26576
Committed: http://github.com/openstack/oslo-incubator/commit/fa84da27458847d90075c9f8d77333b532d7882a
Submitter: Jenkins
Branch: master

commit fa84da27458847d90075c9f8d77333b532d7882a
Author: Zhongyue Luo <email address hidden>
Date: Wed Apr 10 10:31:03 2013 +0800

    Removes created_at, updated_at from ModelBase

    Created a 'TimestampMixin' class.
    Next step is to update Nova which is the only project using oslo.db

    Fixes bug #1119702

    Change-Id: I1ffcc09a2971e6e6102da7ecb855a2837a159baf

Changed in oslo:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in oslo:
milestone: none → havana-1
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in oslo:
milestone: havana-1 → 2013.2
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.