Add Tag, TagKind and ManifestChild tables in prep for new data model
This commit is contained in:
parent
053d918d67
commit
c0653ef2ad
3 changed files with 156 additions and 3 deletions
|
@ -1385,6 +1385,58 @@ class Manifest(BaseModel):
|
|||
)
|
||||
|
||||
|
||||
class TagKind(BaseModel):
|
||||
""" TagKind describes the various kinds of tags that can be found in the registry.
|
||||
"""
|
||||
name = CharField(index=True, unique=True)
|
||||
|
||||
|
||||
class Tag(BaseModel):
|
||||
""" Tag represents a user-facing alias for referencing a Manifest or as an alias to another tag.
|
||||
"""
|
||||
name = CharField()
|
||||
repository = ForeignKeyField(Repository)
|
||||
manifest = ForeignKeyField(Manifest, null=True)
|
||||
lifetime_start_ms = BigIntegerField(default=get_epoch_timestamp_ms)
|
||||
lifetime_end_ms = BigIntegerField(null=True, index=True)
|
||||
hidden = BooleanField(default=False)
|
||||
reverted = BooleanField(default=False)
|
||||
tag_kind = EnumField(TagKind)
|
||||
linked_tag = ForeignKeyField('self', null=True, backref='tag_parents')
|
||||
|
||||
class Meta:
|
||||
database = db
|
||||
read_slaves = (read_slave,)
|
||||
indexes = (
|
||||
(('repository', 'name'), False),
|
||||
(('repository', 'name', 'hidden'), False),
|
||||
(('repository', 'name', 'tag_kind'), False),
|
||||
|
||||
# This unique index prevents deadlocks when concurrently moving and deleting tags
|
||||
(('repository', 'name', 'lifetime_end_ms'), True),
|
||||
)
|
||||
|
||||
|
||||
class ManifestChild(BaseModel):
|
||||
""" ManifestChild represents a relationship between a manifest and its child manifest(s).
|
||||
Multiple manifests can share the same children. Note that since Manifests are stored
|
||||
per-repository, the repository here is a bit redundant, but we do so to make cleanup easier.
|
||||
"""
|
||||
repository = ForeignKeyField(Repository)
|
||||
manifest = ForeignKeyField(Manifest)
|
||||
child_manifest = ForeignKeyField(Manifest)
|
||||
|
||||
class Meta:
|
||||
database = db
|
||||
read_slaves = (read_slave,)
|
||||
indexes = (
|
||||
(('repository', 'manifest'), False),
|
||||
(('repository', 'child_manifest'), False),
|
||||
(('repository', 'manifest', 'child_manifest'), False),
|
||||
(('manifest', 'child_manifest'), True),
|
||||
)
|
||||
|
||||
|
||||
class ManifestLabel(BaseModel):
|
||||
""" ManifestLabel represents a label applied to a Manifest, within a repository.
|
||||
Note that since Manifests are stored per-repository, the repository here is
|
||||
|
@ -1470,7 +1522,8 @@ class TagManifestLabelMap(BaseModel):
|
|||
appr_classes = set([ApprTag, ApprTagKind, ApprBlobPlacementLocation, ApprManifestList,
|
||||
ApprManifestBlob, ApprBlob, ApprManifestListManifest, ApprManifest,
|
||||
ApprBlobPlacement])
|
||||
v22_classes = set([Manifest, ManifestLabel, ManifestBlob, ManifestLegacyImage])
|
||||
v22_classes = set([Manifest, ManifestLabel, ManifestBlob, ManifestLegacyImage, TagKind,
|
||||
ManifestChild, Tag])
|
||||
transition_classes = set([TagManifestToManifest, TagManifestLabelMap])
|
||||
|
||||
is_model = lambda x: inspect.isclass(x) and issubclass(x, BaseModel) and x is not BaseModel
|
||||
|
|
Reference in a new issue