diff options
author | Mart Raudsepp <leio@gentoo.org> | 2016-12-07 02:30:06 +0200 |
---|---|---|
committer | Mart Raudsepp <leio@gentoo.org> | 2016-12-07 02:30:06 +0200 |
commit | f1a5e9bb01bb7fd802e7cf87b4e9dd675e910140 (patch) | |
tree | a143339320ef06e27645f0bc5825fcd538825ed9 | |
parent | frontend: Setup Flask-WTF and use it for following maintainer checkboxes display (diff) | |
download | grumpy-f1a5e9bb01bb7fd802e7cf87b4e9dd675e910140.tar.gz grumpy-f1a5e9bb01bb7fd802e7cf87b4e9dd675e910140.tar.bz2 grumpy-f1a5e9bb01bb7fd802e7cf87b4e9dd675e910140.zip |
models: Add description and last_sync_ts columns for Package
description we will get from package.g.o per-package detailed json,
last_sync_ts will be used to record when that detailed json was
last pulled, so that we can rate-limit as-needed.
If still using sqlite, can DROP TABLE package; and re-create with
./manage.py init
or add the columns manually
ALTER TABLE package ADD COLUMN description VARCHAR(500);
ALTER TABLE package ADD COLUMN last_sync_ts TIMESTAMP NOT NULL;
though that NOT NULL vs default on sqlalchemy's side for now might
pose an issue, solving of which is an easy exercise for those that care
instead of recreating.
-rw-r--r-- | backend/lib/models.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/backend/lib/models.py b/backend/lib/models.py index f842a8a..e06dcf8 100644 --- a/backend/lib/models.py +++ b/backend/lib/models.py @@ -1,3 +1,4 @@ +from datetime import datetime from .. import db @@ -14,6 +15,8 @@ class Package(db.Model): name = db.Column(db.Unicode(128), nullable=False) category_id = db.Column(db.Integer, db.ForeignKey('category.id'), nullable=False) category = db.relationship('Category', backref=db.backref('packages', lazy='dynamic')) + description = db.Column(db.Unicode(500)) + last_sync_ts = db.Column(db.TIMESTAMP, nullable=False, default=datetime.utcfromtimestamp(0)) @property def full_name(self): @@ -31,6 +34,7 @@ class PackageVersion(db.Model): def __repr__(self): return "<PackageVersion '%s/%s-%s'>" % (self.package.category.name, self.package.name, self.version) + maintainer_project_membership_rel_table = db.Table('maintainer_project_membership_rel', db.Column('project_id', db.Integer, db.ForeignKey('maintainer.id')), db.Column('maintainer_id', db.Integer, db.ForeignKey('maintainer.id')), |