diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2018-04-13 16:02:04 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2018-04-13 16:02:04 -0700 |
commit | 1b4017c929b92c313f55606b5ca1339a170c7fdb (patch) | |
tree | 44262c193d2d75a4072bd977225be3772257df05 | |
parent | 5cdd3d34f1932197fdd81d9b03570767f85eebf4 (diff) | |
download | fatcat-1b4017c929b92c313f55606b5ca1339a170c7fdb.tar.gz fatcat-1b4017c929b92c313f55606b5ca1339a170c7fdb.zip |
model tweaks/fixes
-rw-r--r-- | fatcat/models.py | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/fatcat/models.py b/fatcat/models.py index ee73d61e..f1fd31e3 100644 --- a/fatcat/models.py +++ b/fatcat/models.py @@ -18,7 +18,7 @@ from fatcat import db class WorkContrib(db.Model): __tablename__ = "work_contrib" work_rev= db.Column(db.ForeignKey('work_revision.id'), nullable=False, primary_key=True) - creator_id = db.Column(db.ForeignKey('creator_ident.id'), nullable=False, primary_key=True) + creator_ident_id = db.Column(db.ForeignKey('creator_ident.id'), nullable=False, primary_key=True) type = db.Column(db.String, nullable=True) stub = db.Column(db.String, nullable=True) @@ -28,7 +28,7 @@ class WorkContrib(db.Model): class ReleaseContrib(db.Model): __tablename__ = "release_contrib" release_rev = db.Column(db.ForeignKey('release_revision.id'), nullable=False, primary_key=True) - creator_id = db.Column(db.ForeignKey('creator_ident.id'), nullable=False, primary_key=True) + creator_ident_id = db.Column(db.ForeignKey('creator_ident.id'), nullable=False, primary_key=True) type = db.Column(db.String, nullable=True) stub = db.Column(db.String, nullable=True) @@ -39,7 +39,7 @@ class ReleaseRef(db.Model): __tablename__ = "release_ref" id = db.Column(db.Integer, primary_key=True, nullable=False) release_rev = db.Column(db.ForeignKey('release_revision.id'), nullable=False) - target_release_id = db.Column(db.ForeignKey('release_ident.id'), nullable=True) + target_release_ident_id = db.Column(db.ForeignKey('release_ident.id'), nullable=True) index = db.Column(db.Integer, nullable=True) stub = db.Column(db.String, nullable=True) doi = db.Column(db.String, nullable=True) @@ -51,7 +51,7 @@ class FileRelease(db.Model): __tablename__ = "file_release" id = db.Column(db.Integer, primary_key=True, nullable=False) file_rev= db.Column(db.ForeignKey('file_revision.id'), nullable=False) - release_id = db.Column(db.ForeignKey('release_ident.id'), nullable=False) + release_ident_id = db.Column(db.ForeignKey('release_ident.id'), nullable=False) release = db.relationship("ReleaseIdent") file = db.relationship("FileRevision") @@ -76,13 +76,24 @@ class WorkLog(db.Model): # ID is a monotonic int here; important for ordering! id = db.Column(db.Integer, primary_key=True, nullable=False) work_ident_id = db.Column(db.ForeignKey('work_ident.id'), nullable=False) - old_revision_id = db.Column(db.ForeignKey('work_revision.id'), nullable=True) - old_redirect_id = db.Column(db.ForeignKey('work_ident.id'), nullable=True) + #old_revision_id = db.Column(db.ForeignKey('work_revision.id'), nullable=True) + #old_redirect_id = db.Column(db.ForeignKey('work_ident.id'), nullable=True) new_revision_id = db.Column(db.ForeignKey('work_revision.id'), nullable=True) new_redirect_id = db.Column(db.ForeignKey('work_ident.id'), nullable=True) # TODO: is this right? edit_id = db.Column(db.ForeignKey('edit.id')) +class WorkEdit(db.Model): + __tablename__ = 'work_edit' + id = db.Column(db.Integer, primary_key=True, autoincrement=True) + ident_id = db.Column(db.ForeignKey('work_ident.id'), nullable=True) + revision_id = db.Column(db.ForeignKey('work_revision.id'), nullable=True) + redirect_id = db.Column(db.ForeignKey('work_ident.id'), nullable=True) + edit_group = db.Column(db.ForeignKey('edit_group.id'), nullable=True) + editor = db.Column(db.ForeignKey('editor.id'), nullable=False) + comment = db.Column(db.String, nullable=True) + extra_json = db.Column(db.ForeignKey('extra_json.sha1'), nullable=True) + class WorkRevision(db.Model): __tablename__ = 'work_revision' id = db.Column(db.Integer, primary_key=True) @@ -111,7 +122,7 @@ class ReleaseRevision(db.Model): extra_json = db.Column(db.ForeignKey('extra_json.sha1'), nullable=True) work_ident_id = db.ForeignKey('work_ident.id') - container_id = db.Column(db.ForeignKey('container_ident.id'), nullable=True) + container_ident_id = db.Column(db.ForeignKey('container_ident.id'), nullable=True) title = db.Column(db.String, nullable=False) license = db.Column(db.String, nullable=True) # TODO: oa status foreign key release_type = db.Column(db.String) # TODO: foreign key @@ -160,7 +171,7 @@ class ContainerRevision(db.Model): extra_json = db.Column(db.ForeignKey('extra_json.sha1'), nullable=True) name = db.Column(db.String) - #XXX: container_id = db.Column(db.ForeignKey('container_ident.id')) + #XXX: container_ident_id = db.Column(db.ForeignKey('container_ident.id')) publisher = db.Column(db.String) # TODO: foreign key sortname = db.Column(db.String) issn = db.Column(db.String) # TODO: identifier table @@ -184,7 +195,6 @@ class FileRevision(db.Model): url = db.Column(db.Integer) # TODO: URL table releases = db.relationship('FileRelease', lazy='subquery') - #backref=db.backref('backrefs', lazy=True)) class Edit(db.Model): __tablename__ = 'edit' @@ -193,10 +203,11 @@ class Edit(db.Model): editor = db.Column(db.ForeignKey('editor.id'), nullable=False) comment = db.Column(db.String, nullable=True) extra_json = db.Column(db.ForeignKey('extra_json.sha1'), nullable=True) - # WARNING: polymorphic. Represents the id that should end up pointing to + # WARNING: polymorphic. Represents the ident that should end up pointing to # this revision. - # TODO: this doesn't work - entity_id = db.Column(db.Integer, nullable=True) + entity_ident = db.Column(db.Integer, nullable=True) + entity_rev = db.Column(db.Integer, nullable=True) + entity_redirect = db.Column(db.Integer, nullable=True) class EditGroup(db.Model): __tablename__ = 'edit_group' |