← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:stormify-distroarchseries into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:stormify-distroarchseries into launchpad:master.

Commit message:
Convert DistroArchSeries and PocketChroot to Storm

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/450247
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:stormify-distroarchseries into launchpad:master.
diff --git a/lib/lp/archivepublisher/model/ftparchive.py b/lib/lp/archivepublisher/model/ftparchive.py
index 2745cb1..f628253 100644
--- a/lib/lp/archivepublisher/model/ftparchive.py
+++ b/lib/lp/archivepublisher/model/ftparchive.py
@@ -723,7 +723,7 @@ class FTPArchiveHandler:
             Component.id == BinaryPackagePublishingHistory.component_id,
         ]
         select_conditions = [
-            DistroArchSeries.distroseriesID == distroseries.id,
+            DistroArchSeries.distroseries == distroseries,
             BinaryPackagePublishingHistory.archive == self.publisher.archive,
             BinaryPackagePublishingHistory.pocket == pocket,
             BinaryPackagePublishingHistory.status
diff --git a/lib/lp/archivepublisher/publishing.py b/lib/lp/archivepublisher/publishing.py
index 30fee6a..0bb7985 100644
--- a/lib/lp/archivepublisher/publishing.py
+++ b/lib/lp/archivepublisher/publishing.py
@@ -586,7 +586,7 @@ class Publisher:
             BinaryPackagePublishingHistory, *clauses
         )
         return publications.order_by(
-            DistroArchSeries.distroseriesID,
+            DistroArchSeries.distroseries_id,
             BinaryPackagePublishingHistory.pocket,
             DistroArchSeries.architecturetag,
             Desc(BinaryPackagePublishingHistory.id),
@@ -696,7 +696,7 @@ class Publisher:
             [
                 BinaryPackagePublishingHistory.distroarchseries_id
                 == DistroArchSeries.id,
-                DistroArchSeries.distroseriesID == DistroSeries.id,
+                DistroArchSeries.distroseries == DistroSeries.id,
             ]
         )
         binary_suites = (
diff --git a/lib/lp/charms/model/charmrecipe.py b/lib/lp/charms/model/charmrecipe.py
index 73d2aea..e2fbb39 100644
--- a/lib/lp/charms/model/charmrecipe.py
+++ b/lib/lp/charms/model/charmrecipe.py
@@ -494,7 +494,7 @@ class CharmRecipe(StormBase, WebhookTargetMixin):
             for charm_base in store.find(
                 CharmBase,
                 CharmBase.distro_series_id.is_in(
-                    {das.distroseriesID for das in all_buildable_dases}
+                    {das.distroseries_id for das in all_buildable_dases}
                 ),
             )
         }
@@ -502,7 +502,7 @@ class CharmRecipe(StormBase, WebhookTargetMixin):
             das
             for das in all_buildable_dases
             if self._isBuildableArchitectureAllowed(
-                das, charm_base=charm_bases.get(das.distroseriesID)
+                das, charm_base=charm_bases.get(das.distroseries_id)
             )
         ]
 
diff --git a/lib/lp/charms/model/charmrecipebuild.py b/lib/lp/charms/model/charmrecipebuild.py
index 083c7ac..998994e 100644
--- a/lib/lp/charms/model/charmrecipebuild.py
+++ b/lib/lp/charms/model/charmrecipebuild.py
@@ -525,7 +525,7 @@ class CharmRecipeBuildSet(SpecificBuildFarmJobSourceMixin):
             DistroArchSeries, builds, ["distro_arch_series_id"]
         )
         distroserieses = load_related(
-            DistroSeries, distroarchserieses, ["distroseriesID"]
+            DistroSeries, distroarchserieses, ["distroseries_id"]
         )
         load_related(Distribution, distroserieses, ["distributionID"])
         recipes = load_related(CharmRecipe, builds, ["recipe_id"])
diff --git a/lib/lp/code/model/cibuild.py b/lib/lp/code/model/cibuild.py
index 88d5762..d157ccb 100644
--- a/lib/lp/code/model/cibuild.py
+++ b/lib/lp/code/model/cibuild.py
@@ -906,7 +906,7 @@ class CIBuildSet(SpecificBuildFarmJobSourceMixin):
             DistroArchSeries, builds, ["distro_arch_series_id"]
         )
         distroseries = load_related(
-            DistroSeries, distroarchseries, ["distroseriesID"]
+            DistroSeries, distroarchseries, ["distroseries_id"]
         )
         load_related(Distribution, distroseries, ["distributionID"])
 
diff --git a/lib/lp/oci/model/ocirecipe.py b/lib/lp/oci/model/ocirecipe.py
index b0f6857..92d55f0 100644
--- a/lib/lp/oci/model/ocirecipe.py
+++ b/lib/lp/oci/model/ocirecipe.py
@@ -546,7 +546,7 @@ class OCIRecipe(StormBase, WebhookTargetMixin):
             clauses.extend(
                 [
                     DistroArchSeries.enabled,
-                    DistroArchSeries.distroseriesID == DistroSeries.id,
+                    DistroArchSeries.distroseries == DistroSeries.id,
                     DistroSeries.status.is_in(ACTIVE_STATUSES),
                 ]
             )
diff --git a/lib/lp/registry/doc/distribution-mirror.rst b/lib/lp/registry/doc/distribution-mirror.rst
index db50e08..f59f730 100644
--- a/lib/lp/registry/doc/distribution-mirror.rst
+++ b/lib/lp/registry/doc/distribution-mirror.rst
@@ -18,6 +18,7 @@ to create a new mirror you should use the Distribution.newMirror method.
     >>> from lp.registry.interfaces.person import IPersonSet
     >>> from lp.registry.interfaces.pocket import PackagePublishingPocket
     >>> from lp.registry.interfaces.series import SeriesStatus
+    >>> from lp.services.database.interfaces import IStore
     >>> from lp.services.worlddata.interfaces.country import ICountrySet
     >>> from lp.soyuz.model.distroarchseries import DistroArchSeries
     >>> mirrorset = getUtility(IDistributionMirrorSet)
@@ -79,7 +80,7 @@ associated with a given mirror, we use the ensureMirrorDistroArchSeries
 (or ensureMirrorDistroSeriesSource) method.
 
     >>> warty = getUtility(IDistroSeriesSet).get(1)
-    >>> warty_i386 = DistroArchSeries.get(1)
+    >>> warty_i386 = IStore(DistroArchSeries).get(DistroArchSeries, 1)
     >>> pocket = PackagePublishingPocket.RELEASE
     >>> warty_component = warty.components[0]
     >>> warty_i386_mirror = new_mirror.ensureMirrorDistroArchSeries(
@@ -459,8 +460,6 @@ single notification to the distribution's mirror admins.
 Now we delete the MirrorProbeRecord we've just created, to make sure this
 mirror is probed by our prober script.
 
-    >>> from lp.services.database.interfaces import IStore
-
     >>> IStore(proberecord).remove(proberecord)
     >>> transaction.commit()
 
diff --git a/lib/lp/registry/model/distroseries.py b/lib/lp/registry/model/distroseries.py
index d34d571..f17d962 100644
--- a/lib/lp/registry/model/distroseries.py
+++ b/lib/lp/registry/model/distroseries.py
@@ -73,7 +73,6 @@ from lp.services.database.sqlobject import (
     BoolCol,
     ForeignKey,
     IntCol,
-    SQLMultipleJoin,
     SQLObjectNotFound,
     StringCol,
 )
@@ -205,11 +204,11 @@ class DistroSeries(
         default=None,
     )
     changeslist = StringCol(notNull=False, default=None)
-    nominatedarchindep = ForeignKey(
-        dbName="nominatedarchindep",
-        foreignKey="DistroArchSeries",
-        notNull=False,
-        default=None,
+    nominatedarchindep_id = Int(
+        name="nominatedarchindep", allow_none=True, default=None
+    )
+    nominatedarchindep = Reference(
+        nominatedarchindep_id, "DistroArchSeries.id"
     )
     messagecount = IntCol(notNull=True, default=0)
     binarycount = IntCol(notNull=True, default=DEFAULT)
@@ -350,10 +349,10 @@ class DistroSeries(
         )
 
     # DistroArchSeries lookup properties/methods.
-    architectures = SQLMultipleJoin(
-        "DistroArchSeries",
-        joinColumn="distroseries",
-        orderBy="architecturetag",
+    architectures = ReferenceSet(
+        "id",
+        DistroArchSeries.distroseries_id,
+        order_by=DistroArchSeries.architecturetag,
     )
 
     def __getitem__(self, archtag):
@@ -368,8 +367,10 @@ class DistroSeries(
 
     def getDistroArchSeries(self, archtag):
         """See `IDistroSeries`."""
-        item = DistroArchSeries.selectOneBy(
-            distroseries=self, architecturetag=archtag
+        item = (
+            IStore(DistroArchSeries)
+            .find(DistroArchSeries, distroseries=self, architecturetag=archtag)
+            .one()
         )
         if item is None:
             raise NotFoundError(
@@ -384,8 +385,8 @@ class DistroSeries(
             Store.of(self)
             .find(
                 DistroArchSeries,
-                DistroArchSeries.distroseriesID == self.id,
-                DistroArchSeries.processor_id == processor.id,
+                DistroArchSeries.distroseries == self,
+                DistroArchSeries.processor == processor,
             )
             .one()
         )
@@ -420,7 +421,7 @@ class DistroSeries(
             .find(
                 DistroArchSeries,
                 DistroArchSeries.distroseries == self,
-                DistroArchSeries.enabled == True,
+                Is(DistroArchSeries.enabled, True),
             )
             .order_by(DistroArchSeries.architecturetag)
         )
@@ -1149,7 +1150,7 @@ class DistroSeries(
             IStore(BinaryPackagePublishingHistory)
             .find(
                 BinaryPackagePublishingHistory,
-                DistroArchSeries.distroseriesID == self.id,
+                DistroArchSeries.distroseries == self,
                 BinaryPackagePublishingHistory.distroarchseries_id
                 == DistroArchSeries.id,
                 BinaryPackagePublishingHistory.archive_id.is_in(
@@ -1335,7 +1336,7 @@ class DistroSeries(
         self, architecturetag, processor, official, owner, enabled=True
     ):
         """See `IDistroSeries`."""
-        return DistroArchSeries(
+        das = DistroArchSeries(
             architecturetag=architecturetag,
             processor=processor,
             official=official,
@@ -1343,6 +1344,8 @@ class DistroSeries(
             owner=owner,
             enabled=enabled,
         )
+        IStore(das).flush()
+        return das
 
     def newMilestone(
         self, name, dateexpected=None, summary=None, code_name=None, tags=None
diff --git a/lib/lp/registry/vocabularies.py b/lib/lp/registry/vocabularies.py
index 4f334f8..e8932cd 100644
--- a/lib/lp/registry/vocabularies.py
+++ b/lib/lp/registry/vocabularies.py
@@ -1808,7 +1808,7 @@ class DistroSeriesDerivationVocabulary(FilteredVocabularyBase):
             return self.find_terms(where)
         else:
             # Select only the series with architectures setup in LP.
-            where.append(DistroSeries.id == DistroArchSeries.distroseriesID)
+            where.append(DistroSeries.id == DistroArchSeries.distroseries_id)
             where.append(DistroSeries.distribution != self.distribution)
             return self.find_terms(where)
 
diff --git a/lib/lp/snappy/model/snap.py b/lib/lp/snappy/model/snap.py
index 286d95b..c742fc2 100644
--- a/lib/lp/snappy/model/snap.py
+++ b/lib/lp/snappy/model/snap.py
@@ -561,7 +561,7 @@ class Snap(StormBase, WebhookTargetMixin):
             clauses.extend(
                 [
                     DistroArchSeries.enabled,
-                    DistroArchSeries.distroseriesID == DistroSeries.id,
+                    DistroArchSeries.distroseries == DistroSeries.id,
                     DistroSeries.status.is_in(ACTIVE_STATUSES),
                 ]
             )
diff --git a/lib/lp/snappy/model/snapbuild.py b/lib/lp/snappy/model/snapbuild.py
index 4fdd7a0..174d586 100644
--- a/lib/lp/snappy/model/snapbuild.py
+++ b/lib/lp/snappy/model/snapbuild.py
@@ -609,7 +609,7 @@ class SnapBuildSet(SpecificBuildFarmJobSourceMixin):
             DistroArchSeries, builds, ["distro_arch_series_id"]
         )
         distroseries = load_related(
-            DistroSeries, distroarchseries, ["distroseriesID"]
+            DistroSeries, distroarchseries, ["distroseries_id"]
         )
         load_related(Distribution, distroseries, ["distributionID"])
         snaps = load_related(Snap, builds, ["snap_id"])
diff --git a/lib/lp/soyuz/adapters/overrides.py b/lib/lp/soyuz/adapters/overrides.py
index b71a12e..01fe786 100644
--- a/lib/lp/soyuz/adapters/overrides.py
+++ b/lib/lp/soyuz/adapters/overrides.py
@@ -341,7 +341,7 @@ class FromExistingOverridePolicy(BaseOverridePolicy):
             other_conditions.extend(
                 [
                     BinaryPackagePublishingHistory.archive == self.archive,
-                    DistroArchSeries.distroseriesID == self.distroseries.id,
+                    DistroArchSeries.distroseries == self.distroseries,
                     BinaryPackagePublishingHistory.distroarchseries_id
                     == DistroArchSeries.id,
                 ]
diff --git a/lib/lp/soyuz/doc/distroarchseriesbinarypackage.rst b/lib/lp/soyuz/doc/distroarchseriesbinarypackage.rst
index 90fd4b1..6225b4b 100644
--- a/lib/lp/soyuz/doc/distroarchseriesbinarypackage.rst
+++ b/lib/lp/soyuz/doc/distroarchseriesbinarypackage.rst
@@ -8,7 +8,7 @@ Distro Arch Series Binary Package
     >>> from lp.soyuz.model.distroarchseriesbinarypackage import (
     ...     DistroArchSeriesBinaryPackage,
     ... )
-    >>> hoary_i386 = DistroArchSeries.get(6)
+    >>> hoary_i386 = IStore(DistroArchSeries).get(DistroArchSeries, 6)
     >>> pmount_name = (
     ...     IStore(BinaryPackageName)
     ...     .find(BinaryPackageName, name="pmount")
@@ -271,7 +271,7 @@ Then, supersede all pmount publications in warty for pmount (this sets
 us up to demonstrate bug 208233).
 
     >>> switch_dbuser("archivepublisher")
-    >>> warty_i386 = DistroArchSeries.get(1)
+    >>> warty_i386 = IStore(DistroArchSeries).get(DistroArchSeries, 1)
     >>> pmount_name = (
     ...     IStore(BinaryPackageName)
     ...     .find(BinaryPackageName, name="pmount")
diff --git a/lib/lp/soyuz/doc/distroarchseriesbinarypackagerelease.rst b/lib/lp/soyuz/doc/distroarchseriesbinarypackagerelease.rst
index c307b56..4c687b7 100644
--- a/lib/lp/soyuz/doc/distroarchseriesbinarypackagerelease.rst
+++ b/lib/lp/soyuz/doc/distroarchseriesbinarypackagerelease.rst
@@ -10,10 +10,10 @@ Distro Arch Release Binary Package Release
 
 Grab the relevant DARs and BPRs:
 
-    >>> warty = DistroArchSeries.get(1)
+    >>> warty = IStore(DistroArchSeries).get(DistroArchSeries, 1)
     >>> print(warty.distroseries.name)
     warty
-    >>> hoary = DistroArchSeries.get(6)
+    >>> hoary = IStore(DistroArchSeries).get(DistroArchSeries, 6)
     >>> print(hoary.distroseries.name)
     hoary
 
diff --git a/lib/lp/soyuz/doc/gina-multiple-arch.rst b/lib/lp/soyuz/doc/gina-multiple-arch.rst
index 86b6820..7b41807 100644
--- a/lib/lp/soyuz/doc/gina-multiple-arch.rst
+++ b/lib/lp/soyuz/doc/gina-multiple-arch.rst
@@ -265,12 +265,17 @@ DSC.
 Check that we publishing bdftopcf into the correct distroarchseries:
 
     >>> processor = getUtility(IProcessorSet).getByName("386")
-    >>> dar = DistroArchSeries.selectOneBy(
-    ...     distroseriesID=dapper.id,
-    ...     processor_id=processor.id,
-    ...     architecturetag="i386",
-    ...     official=True,
-    ...     ownerID=celebs.launchpad_developers.id,
+    >>> dar = (
+    ...     IStore(DistroArchSeries)
+    ...     .find(
+    ...         DistroArchSeries,
+    ...         distroseries=dapper,
+    ...         processor=processor,
+    ...         architecturetag="i386",
+    ...         official=True,
+    ...         owner=celebs.launchpad_developers,
+    ...     )
+    ...     .one()
     ... )
     >>> print(dar.architecturetag)
     i386
diff --git a/lib/lp/soyuz/model/archive.py b/lib/lp/soyuz/model/archive.py
index 71b8c33..6023353 100644
--- a/lib/lp/soyuz/model/archive.py
+++ b/lib/lp/soyuz/model/archive.py
@@ -1122,7 +1122,7 @@ class Archive(SQLBase):
             dases = load_related(
                 DistroArchSeries, bpphs, ["distroarchseries_id"]
             )
-            load_related(DistroSeries, dases, ["distroseriesID"])
+            load_related(DistroSeries, dases, ["distroseries_id"])
 
         if eager_load:
             result = DecoratedResultSet(result, pre_iter_hook=eager_load_api)
@@ -1156,7 +1156,7 @@ class Archive(SQLBase):
             [
                 BinaryPackagePublishingHistory.distroarchseries_id
                 == DistroArchSeries.id,
-                DistroArchSeries.distroseriesID == DistroSeries.id,
+                DistroArchSeries.distroseries == DistroSeries.id,
             ]
         )
 
@@ -1167,7 +1167,7 @@ class Archive(SQLBase):
         # It includes all architecture-independent binaries only once and the
         # architecture-specific built for 'nominatedarchindep'.
         nominated_arch_independent_clauses = clauses + [
-            DistroSeries.nominatedarchindepID
+            DistroSeries.nominatedarchindep_id
             == BinaryPackagePublishingHistory.distroarchseries_id,
         ]
         nominated_arch_independents = store.find(
@@ -1177,7 +1177,7 @@ class Archive(SQLBase):
         # Retrieve all architecture-specific binary publications except
         # 'nominatedarchindep' (already included in the previous query).
         no_nominated_arch_independent_clauses = clauses + [
-            DistroSeries.nominatedarchindepID
+            DistroSeries.nominatedarchindep_id
             != BinaryPackagePublishingHistory.distroarchseries_id,
             BinaryPackageRelease.architecturespecific == True,
         ]
@@ -2962,7 +2962,7 @@ class Archive(SQLBase):
 
         clauses = [
             Processor.id == DistroArchSeries.processor_id,
-            DistroArchSeries.distroseriesID == DistroSeries.id,
+            DistroArchSeries.distroseries == DistroSeries.id,
             DistroSeries.distribution == self.distribution,
         ]
         if not self.permit_obsolete_series_uploads:
diff --git a/lib/lp/soyuz/model/binarypackagebuild.py b/lib/lp/soyuz/model/binarypackagebuild.py
index 68167ac..6cf2ef7 100644
--- a/lib/lp/soyuz/model/binarypackagebuild.py
+++ b/lib/lp/soyuz/model/binarypackagebuild.py
@@ -943,7 +943,7 @@ class BinaryPackageBuildSet(SpecificBuildFarmJobSourceMixin):
         das = load_related(DistroArchSeries, builds, ["distro_arch_series_id"])
         archives = load_related(Archive, builds, ["archive_id"])
         load_related(Person, archives, ["ownerID"])
-        distroseries = load_related(DistroSeries, das, ["distroseriesID"])
+        distroseries = load_related(DistroSeries, das, ["distroseries_id"])
         load_related(Distribution, distroseries, ["distributionID"])
 
     def getByBuildFarmJobs(self, build_farm_jobs):
diff --git a/lib/lp/soyuz/model/distributionsourcepackagerelease.py b/lib/lp/soyuz/model/distributionsourcepackagerelease.py
index d915c18..d6b3ffa 100644
--- a/lib/lp/soyuz/model/distributionsourcepackagerelease.py
+++ b/lib/lp/soyuz/model/distributionsourcepackagerelease.py
@@ -169,7 +169,7 @@ class DistributionSourcePackageRelease:
             ),
             Join(
                 DistroSeries,
-                DistroArchSeries.distroseriesID == DistroSeries.id,
+                DistroArchSeries.distroseries == DistroSeries.id,
             ),
             Join(
                 BinaryPackageRelease,
@@ -253,7 +253,7 @@ class DistributionSourcePackageRelease:
         binaries = store.using(*tables).find(
             result_row,
             And(
-                DistroArchSeries.distroseriesID == distroseries.id,
+                DistroArchSeries.distroseries == distroseries,
                 BinaryPackagePublishingHistory.archive_id.is_in(archive_ids),
                 BinaryPackageBuild.source_package_release
                 == self.sourcepackagerelease,
diff --git a/lib/lp/soyuz/model/distroarchseries.py b/lib/lp/soyuz/model/distroarchseries.py
index cb9b669..c2960e9 100644
--- a/lib/lp/soyuz/model/distroarchseries.py
+++ b/lib/lp/soyuz/model/distroarchseries.py
@@ -6,7 +6,7 @@ __all__ = ["DistroArchSeries", "PocketChroot"]
 import hashlib
 from io import BytesIO
 
-from storm.locals import Int, Join, Or, Reference, ReferenceSet
+from storm.locals import Bool, Int, Join, Or, Reference, ReferenceSet, Unicode
 from storm.store import EmptyResultSet
 from zope.component import getUtility
 from zope.interface import implementer
@@ -19,13 +19,7 @@ from lp.services.database.constants import DEFAULT
 from lp.services.database.decoratedresultset import DecoratedResultSet
 from lp.services.database.enumcol import DBEnum
 from lp.services.database.interfaces import IStore
-from lp.services.database.sqlbase import SQLBase
-from lp.services.database.sqlobject import (
-    BoolCol,
-    ForeignKey,
-    IntCol,
-    StringCol,
-)
+from lp.services.database.stormbase import StormBase
 from lp.services.database.stormexpr import fti_search, rank_by_fti
 from lp.services.librarian.interfaces import ILibraryFileAliasSet
 from lp.services.webapp.publisher import (
@@ -52,33 +46,48 @@ from lp.soyuz.model.binarypackagerelease import BinaryPackageRelease
 
 
 @implementer(IDistroArchSeries, IHasBuildRecords)
-class DistroArchSeries(SQLBase):
-    _table = "DistroArchSeries"
-    _defaultOrder = "id"
+class DistroArchSeries(StormBase):
+    __storm_table__ = "DistroArchSeries"
+    __storm_order__ = "id"
 
-    distroseries = ForeignKey(
-        dbName="distroseries", foreignKey="DistroSeries", notNull=True
-    )
+    id = Int(primary=True)
+    distroseries_id = Int(name="distroseries", allow_none=False)
+    distroseries = Reference(distroseries_id, "DistroSeries.id")
     processor_id = Int(name="processor", allow_none=False)
     processor = Reference(processor_id, Processor.id)
-    architecturetag = StringCol(notNull=True)
-    official = BoolCol(notNull=True)
-    owner = ForeignKey(
-        dbName="owner",
-        foreignKey="Person",
-        storm_validator=validate_public_person,
-        notNull=True,
+    architecturetag = Unicode(allow_none=False)
+    official = Bool(allow_none=False)
+    owner_id = Int(
+        name="owner", validator=validate_public_person, allow_none=False
     )
-    package_count = IntCol(notNull=True, default=DEFAULT)
-    enabled = BoolCol(notNull=False, default=True)
+    owner = Reference(owner_id, "Person.id")
+    package_count = Int(allow_none=False, default=DEFAULT)
+    enabled = Bool(allow_none=True, default=True)
 
     packages = ReferenceSet(
-        "<primary key>",
+        "id",
         "BinaryPackagePublishingHistory.distroarchseries_id",
         "BinaryPackagePublishingHistory.binarypackagerelease_id",
         "BinaryPackageRelease.id",
     )
 
+    def __init__(
+        self,
+        distroseries,
+        processor,
+        architecturetag,
+        official,
+        owner,
+        enabled=True,
+    ):
+        super().__init__()
+        self.distroseries = distroseries
+        self.processor = processor
+        self.architecturetag = architecturetag
+        self.official = official
+        self.owner = owner
+        self.enabled = enabled
+
     def __getitem__(self, name):
         return self.getBinaryPackage(name)
 
@@ -417,12 +426,13 @@ class DistroArchSeries(SQLBase):
 
 
 @implementer(IPocketChroot)
-class PocketChroot(SQLBase):
-    _table = "PocketChroot"
+class PocketChroot(StormBase):
+    __storm_table__ = "PocketChroot"
 
-    distroarchseries = ForeignKey(
-        dbName="distroarchseries", foreignKey="DistroArchSeries", notNull=True
-    )
+    id = Int(primary=True)
+
+    distroarchseries_id = Int(name="distroarchseries", allow_none=False)
+    distroarchseries = Reference(distroarchseries_id, "DistroArchSeries.id")
 
     pocket = DBEnum(
         enum=PackagePublishingPocket,
@@ -430,10 +440,24 @@ class PocketChroot(SQLBase):
         allow_none=False,
     )
 
-    chroot = ForeignKey(dbName="chroot", foreignKey="LibraryFileAlias")
+    chroot_id = Int(name="chroot", allow_none=True)
+    chroot = Reference(chroot_id, "LibraryFileAlias.id")
 
     image_type = DBEnum(
         enum=BuildBaseImageType,
         default=BuildBaseImageType.CHROOT,
         allow_none=False,
     )
+
+    def __init__(
+        self,
+        distroarchseries,
+        pocket,
+        chroot=None,
+        image_type=BuildBaseImageType.CHROOT,
+    ):
+        super().__init__()
+        self.distroarchseries = distroarchseries
+        self.pocket = pocket
+        self.chroot = chroot
+        self.image_type = image_type
diff --git a/lib/lp/soyuz/model/packagecloner.py b/lib/lp/soyuz/model/packagecloner.py
index 56bdf29..659345d 100644
--- a/lib/lp/soyuz/model/packagecloner.py
+++ b/lib/lp/soyuz/model/packagecloner.py
@@ -170,7 +170,7 @@ class PackageCloner:
                 %s as pocket,
                 bpph.binarypackagename
             """ % sqlvalues(
-            destination_das,
+            destination_das.id,
             destination.archive,
             UTC_NOW,
             UTC_NOW,
@@ -184,7 +184,7 @@ class PackageCloner:
                 bpph.pocket = %s AND
                 bpph.archive = %s
             """ % sqlvalues(
-            origin_das,
+            origin_das.id,
             PackagePublishingStatus.PENDING,
             PackagePublishingStatus.PUBLISHED,
             origin.pocket,
diff --git a/lib/lp/soyuz/model/publishing.py b/lib/lp/soyuz/model/publishing.py
index b5ded2d..7bfee02 100644
--- a/lib/lp/soyuz/model/publishing.py
+++ b/lib/lp/soyuz/model/publishing.py
@@ -406,7 +406,7 @@ class SourcePackagePublishingHistory(StormBase, ArchivePublisherBase):
                 BinaryPackageBuild.id == BinaryPackageRelease.build_id,
                 BinaryPackageBuild.source_package_release_id
                 == self.sourcepackagerelease_id,
-                DistroArchSeries.distroseriesID == self.distroseries_id,
+                DistroArchSeries.distroseries == self.distroseries_id,
             )
             .order_by(Desc(BinaryPackagePublishingHistory.id))
         )
@@ -1881,7 +1881,7 @@ class PublishingSet:
             BinaryPackageRelease.build == BinaryPackageBuild.id,
             BinaryPackageRelease.binarypackagename_id == BinaryPackageName.id,
             SourcePackagePublishingHistory.distroseries_id
-            == DistroArchSeries.distroseriesID,
+            == DistroArchSeries.distroseries_id,
             BinaryPackagePublishingHistory.distroarchseries_id
             == DistroArchSeries.id,
             BinaryPackagePublishingHistory.binarypackagerelease
@@ -2066,7 +2066,7 @@ class PublishingSet:
             BinaryPackagePublishingHistory.archive == archive,
             BinaryPackagePublishingHistory.distroarchseries_id
             == DistroArchSeries.id,
-            DistroArchSeries.distroseriesID == distroseries.id,
+            DistroArchSeries.distroseries == distroseries,
             BinaryPackagePublishingHistory.pocket == pocket,
             BinaryPackagePublishingHistory.status.is_in(
                 active_publishing_status
diff --git a/lib/lp/soyuz/scripts/gina/handlers.py b/lib/lp/soyuz/scripts/gina/handlers.py
index ae2d08c..1fed4c3 100644
--- a/lib/lp/soyuz/scripts/gina/handlers.py
+++ b/lib/lp/soyuz/scripts/gina/handlers.py
@@ -211,8 +211,14 @@ class ImporterHandler:
             return
 
         # Get distroarchseries and processor from the architecturetag.
-        das = DistroArchSeries.selectOneBy(
-            distroseriesID=self.distroseries.id, architecturetag=archtag
+        das = (
+            IStore(DistroArchSeries)
+            .find(
+                DistroArchSeries,
+                distroseries=self.distroseries,
+                architecturetag=archtag,
+            )
+            .one()
         )
         if not das:
             raise DataSetupError(
diff --git a/lib/lp/soyuz/scripts/retrydepwait.py b/lib/lp/soyuz/scripts/retrydepwait.py
index 45cfeb0..8fc7f2e 100644
--- a/lib/lp/soyuz/scripts/retrydepwait.py
+++ b/lib/lp/soyuz/scripts/retrydepwait.py
@@ -52,12 +52,12 @@ class RetryDepwaitTunableLoop(TunableLoop):
         load_related(SourcePackageName, sprs, ["sourcepackagenameID"])
         chroots = IStore(PocketChroot).find(
             PocketChroot,
-            PocketChroot.distroarchseriesID.is_in(
+            PocketChroot.distroarchseries_id.is_in(
                 b.distro_arch_series_id for b in bpbs
             ),
             PocketChroot.chroot != None,
         )
-        chroot_series = {chroot.distroarchseriesID for chroot in chroots}
+        chroot_series = {chroot.distroarchseries_id for chroot in chroots}
         for build in bpbs:
             das = build.distro_arch_series
             if (
diff --git a/lib/lp/soyuz/tests/test_distributionsourcepackagerelease.py b/lib/lp/soyuz/tests/test_distributionsourcepackagerelease.py
index 56f4c43..1140263 100644
--- a/lib/lp/soyuz/tests/test_distributionsourcepackagerelease.py
+++ b/lib/lp/soyuz/tests/test_distributionsourcepackagerelease.py
@@ -6,6 +6,7 @@
 from storm.store import Store
 from testtools.matchers import Equals, LessThan
 
+from lp.services.database.interfaces import IStore
 from lp.soyuz.enums import PackagePublishingStatus
 from lp.soyuz.model.distributionsourcepackagerelease import (
     DistributionSourcePackageRelease,
@@ -124,7 +125,9 @@ class TestDistributionSourcePackageRelease(TestCaseWithFactory):
         sourcepackagename = self.sourcepackagerelease.sourcepackagename
         publisher = SoyuzTestPublisher()
         publisher.updatePackageCache(self.distroarchseries.distroseries)
-        self.distroarchseries = DistroArchSeries.get(self.distroarchseries.id)
+        self.distroarchseries = IStore(DistroArchSeries).get(
+            DistroArchSeries, self.distroarchseries.id
+        )
         distribution = self.distroarchseries.distroseries.distribution
         releases = distribution.getCurrentSourceReleases([sourcepackagename])
         [(distribution_sourcepackage, dsp_release)] = releases.items()
diff --git a/lib/lp/soyuz/vocabularies.py b/lib/lp/soyuz/vocabularies.py
index 28b654f..b98639c 100644
--- a/lib/lp/soyuz/vocabularies.py
+++ b/lib/lp/soyuz/vocabularies.py
@@ -43,11 +43,15 @@ class ComponentVocabulary(StormVocabularyBase):
         return SimpleTerm(obj, obj.id, obj.name)
 
 
-class FilteredDistroArchSeriesVocabulary(SQLObjectVocabularyBase):
+class FilteredDistroArchSeriesVocabulary(StormVocabularyBase):
     """All arch series of a particular distribution."""
 
     _table = DistroArchSeries
-    _orderBy = ["DistroSeries.version", "architecturetag", "id"]
+    _order_by = [
+        "DistroSeries.version",
+        DistroArchSeries.architecturetag,
+        DistroArchSeries.id,
+    ]
 
     def toTerm(self, obj):
         name = "%s %s (%s)" % (
@@ -64,7 +68,7 @@ class FilteredDistroArchSeriesVocabulary(SQLObjectVocabularyBase):
                 IStore(DistroSeries)
                 .find(
                     self._table,
-                    DistroSeries.id == DistroArchSeries.distroseriesID,
+                    DistroSeries.id == DistroArchSeries.distroseries_id,
                     DistroSeries.distributionID == distribution.id,
                 )
                 .order_by(*self._orderBy)