Phase 3 of Appr migration
Deletes the old models and their code
This commit is contained in:
parent
223077ef53
commit
487edf0ba1
9 changed files with 218 additions and 167 deletions
127
data/database.py
127
data/database.py
|
@ -471,7 +471,7 @@ class User(BaseModel):
|
|||
TagManifest, AccessToken, OAuthAccessToken, BlobUpload,
|
||||
RepositoryNotification, OAuthAuthorizationCode,
|
||||
RepositoryActionCount, TagManifestLabel,
|
||||
TeamSync, RepositorySearchScore, DeletedNamespace} | cnr_classes | appr_classes
|
||||
TeamSync, RepositorySearchScore, DeletedNamespace} | appr_classes
|
||||
delete_instance_filtered(self, User, delete_nullable, skip_transitive_deletes)
|
||||
|
||||
|
||||
|
@ -619,7 +619,7 @@ class Repository(BaseModel):
|
|||
# are cleaned up directly
|
||||
skip_transitive_deletes = {RepositoryTag, RepositoryBuild, RepositoryBuildTrigger, BlobUpload,
|
||||
Image, TagManifest, TagManifestLabel, Label, DerivedStorageForImage,
|
||||
RepositorySearchScore} | cnr_classes | appr_classes
|
||||
RepositorySearchScore} | appr_classes
|
||||
|
||||
delete_instance_filtered(self, Repository, delete_nullable, skip_transitive_deletes)
|
||||
|
||||
|
@ -1231,17 +1231,6 @@ class TagManifestLabel(BaseModel):
|
|||
)
|
||||
|
||||
|
||||
class Blob(BaseModel):
|
||||
""" Blob represents a content-addressable object stored outside of the database.
|
||||
This is deprecated in favor of ApprBlob.
|
||||
"""
|
||||
digest = CharField(index=True, unique=True)
|
||||
media_type = EnumField(MediaType)
|
||||
size = BigIntegerField()
|
||||
uncompressed_size = BigIntegerField(null=True)
|
||||
|
||||
|
||||
|
||||
class ApprBlob(BaseModel):
|
||||
""" ApprBlob represents a content-addressable object stored outside of the database.
|
||||
"""
|
||||
|
@ -1251,34 +1240,12 @@ class ApprBlob(BaseModel):
|
|||
uncompressed_size = BigIntegerField(null=True)
|
||||
|
||||
|
||||
class BlobPlacementLocation(BaseModel):
|
||||
""" BlobPlacementLocation is an enumeration of the possible storage locations for Blobs.
|
||||
This is deprecated in favor of ApprBlobPlacementLocation.
|
||||
"""
|
||||
name = CharField(index=True, unique=True)
|
||||
|
||||
|
||||
class ApprBlobPlacementLocation(BaseModel):
|
||||
""" ApprBlobPlacementLocation is an enumeration of the possible storage locations for ApprBlobs.
|
||||
"""
|
||||
name = CharField(index=True, unique=True)
|
||||
|
||||
|
||||
class BlobPlacement(BaseModel):
|
||||
""" BlobPlacement represents the location of a Blob.
|
||||
This is deprecated in favor of ApprBlobPlacement.
|
||||
"""
|
||||
blob = ForeignKeyField(Blob)
|
||||
location = EnumField(BlobPlacementLocation)
|
||||
|
||||
class Meta:
|
||||
database = db
|
||||
read_slaves = (read_slave,)
|
||||
indexes = (
|
||||
(('blob', 'location'), True),
|
||||
)
|
||||
|
||||
|
||||
class ApprBlobPlacement(BaseModel):
|
||||
""" ApprBlobPlacement represents the location of a Blob.
|
||||
"""
|
||||
|
@ -1293,15 +1260,6 @@ class ApprBlobPlacement(BaseModel):
|
|||
)
|
||||
|
||||
|
||||
class Manifest(BaseModel):
|
||||
""" Manifest represents the metadata and collection of blobs that comprise a container image.
|
||||
This is deprecated in favor of ApprManifest.
|
||||
"""
|
||||
digest = CharField(index=True, unique=True)
|
||||
media_type = EnumField(MediaType)
|
||||
manifest_json = JSONField()
|
||||
|
||||
|
||||
class ApprManifest(BaseModel):
|
||||
""" ApprManifest represents the metadata and collection of blobs that comprise an Appr image.
|
||||
"""
|
||||
|
@ -1310,21 +1268,6 @@ class ApprManifest(BaseModel):
|
|||
manifest_json = JSONField()
|
||||
|
||||
|
||||
class ManifestBlob(BaseModel):
|
||||
""" ManifestBlob is a many-to-many relation table linking Manifests and Blobs.
|
||||
This is deprecated in favor of ApprManifestBlob.
|
||||
"""
|
||||
manifest = ForeignKeyField(Manifest, index=True)
|
||||
blob = ForeignKeyField(Blob, index=True)
|
||||
|
||||
class Meta:
|
||||
database = db
|
||||
read_slaves = (read_slave,)
|
||||
indexes = (
|
||||
(('manifest', 'blob'), True),
|
||||
)
|
||||
|
||||
|
||||
class ApprManifestBlob(BaseModel):
|
||||
""" ApprManifestBlob is a many-to-many relation table linking ApprManifests and ApprBlobs.
|
||||
"""
|
||||
|
@ -1339,16 +1282,6 @@ class ApprManifestBlob(BaseModel):
|
|||
)
|
||||
|
||||
|
||||
class ManifestList(BaseModel):
|
||||
""" ManifestList represents all of the various manifests that compose a Tag.
|
||||
This is deprecated in favor of ApprManifestList.
|
||||
"""
|
||||
digest = CharField(index=True, unique=True)
|
||||
manifest_list_json = JSONField()
|
||||
schema_version = CharField()
|
||||
media_type = EnumField(MediaType)
|
||||
|
||||
|
||||
class ApprManifestList(BaseModel):
|
||||
""" ApprManifestList represents all of the various Appr manifests that compose an ApprTag.
|
||||
"""
|
||||
|
@ -1358,45 +1291,12 @@ class ApprManifestList(BaseModel):
|
|||
media_type = EnumField(MediaType)
|
||||
|
||||
|
||||
class TagKind(BaseModel):
|
||||
""" TagKind is a enumtable to reference tag kinds.
|
||||
This model is deprecated in favor of ApprTagKind.
|
||||
"""
|
||||
name = CharField(index=True, unique=True)
|
||||
|
||||
|
||||
class ApprTagKind(BaseModel):
|
||||
""" ApprTagKind is a enumtable to reference tag kinds.
|
||||
"""
|
||||
name = CharField(index=True, unique=True)
|
||||
|
||||
|
||||
class Tag(BaseModel):
|
||||
""" Tag represents a user-facing alias for referencing a ManifestList.
|
||||
This model is deprecated in favor of ApprTag.
|
||||
"""
|
||||
name = CharField()
|
||||
repository = ForeignKeyField(Repository)
|
||||
manifest_list = ForeignKeyField(ManifestList, null=True)
|
||||
lifetime_start = BigIntegerField(default=get_epoch_timestamp_ms)
|
||||
lifetime_end = BigIntegerField(null=True, index=True)
|
||||
hidden = BooleanField(default=False)
|
||||
reverted = BooleanField(default=False)
|
||||
protected = BooleanField(default=False)
|
||||
tag_kind = EnumField(TagKind)
|
||||
linked_tag = ForeignKeyField('self', null=True, related_name='tag_parents')
|
||||
|
||||
class Meta:
|
||||
database = db
|
||||
read_slaves = (read_slave,)
|
||||
indexes = (
|
||||
(('repository', 'name'), False),
|
||||
(('repository', 'name', 'hidden'), False),
|
||||
# This unique index prevents deadlocks when concurrently moving and deleting tags
|
||||
(('repository', 'name', 'lifetime_end'), True),
|
||||
)
|
||||
|
||||
|
||||
class ApprTag(BaseModel):
|
||||
""" ApprTag represents a user-facing alias for referencing an ApprManifestList.
|
||||
"""
|
||||
|
@ -1421,30 +1321,9 @@ class ApprTag(BaseModel):
|
|||
(('repository', 'name', 'lifetime_end'), True),
|
||||
)
|
||||
|
||||
Channel = Tag.alias()
|
||||
ApprChannel = ApprTag.alias()
|
||||
|
||||
|
||||
class ManifestListManifest(BaseModel):
|
||||
""" ManifestListManifest is a many-to-many relation table linking ManifestLists and Manifests.
|
||||
This model is deprecated in favor of ApprManifestListManifest.
|
||||
"""
|
||||
manifest_list = ForeignKeyField(ManifestList, index=True)
|
||||
manifest = ForeignKeyField(Manifest, index=True)
|
||||
operating_system = CharField(null=True)
|
||||
architecture = CharField(null=True)
|
||||
platform_json = JSONField(null=True)
|
||||
media_type = EnumField(MediaType)
|
||||
|
||||
class Meta:
|
||||
database = db
|
||||
read_slaves = (read_slave,)
|
||||
indexes = (
|
||||
(('manifest_list', 'operating_system', 'architecture', 'media_type'), False),
|
||||
(('manifest_list', 'media_type'), False),
|
||||
)
|
||||
|
||||
|
||||
class ApprManifestListManifest(BaseModel):
|
||||
""" ApprManifestListManifest is a many-to-many relation table linking ApprManifestLists and
|
||||
ApprManifests.
|
||||
|
@ -1484,8 +1363,6 @@ class AppSpecificAuthToken(BaseModel):
|
|||
)
|
||||
|
||||
|
||||
cnr_classes = set([Tag, TagKind, BlobPlacementLocation, ManifestList, ManifestBlob, Blob,
|
||||
ManifestListManifest, Manifest, BlobPlacement])
|
||||
appr_classes = set([ApprTag, ApprTagKind, ApprBlobPlacementLocation, ApprManifestList,
|
||||
ApprManifestBlob, ApprBlob, ApprManifestListManifest, ApprManifest,
|
||||
ApprBlobPlacement])
|
||||
|
|
Reference in a new issue