Fix the V22 phase 1 migrations to use new tables for mapping rather than editing existing tables

The ALTER TABLE operations previously used were causing the DB to die when run on the production TagManifest table which has 7 million rows. We instead now use new mapping tables, which is less nice, but these are temporary anyway, so hopefully we only have to deal with their ugliness for a short duration.
This commit is contained in:
Joseph Schorr 2018-08-06 16:58:27 -04:00
parent 7068010751
commit 89582438cd
7 changed files with 128 additions and 57 deletions

View file

@ -11,7 +11,7 @@ from playhouse.test_utils import assert_query_count
from data import model, database
from data.database import (Image, ImageStorage, DerivedStorageForImage, Label, TagManifestLabel,
ApprBlob, Manifest, TagManifest)
ApprBlob, Manifest, TagManifest, TagManifestToManifest)
from image.docker.schema1 import DockerSchema1ManifestBuilder
from test.fixtures import *
@ -162,7 +162,7 @@ def _get_dangling_label_count():
def _get_dangling_manifest_count():
manifest_ids = set([current.id for current in Manifest.select()])
referenced_by_tag_manifest = set([manifest.manifest_id for manifest in TagManifest.select()])
referenced_by_tag_manifest = set([tmt.manifest_id for tmt in TagManifestToManifest.select()])
return len(manifest_ids - referenced_by_tag_manifest)