]> git.ipfire.org Git - pbs.git/commitdiff
distros: Create tag as a generated column
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 22 Jan 2025 13:23:40 +0000 (13:23 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 22 Jan 2025 13:23:40 +0000 (13:23 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/distros.py
src/database.sql

index b70b59e76046beeb0db8ec046176c44784598737..04a0415d504af69fa702381923b385b1c0feff95 100644 (file)
@@ -70,7 +70,7 @@ class Distros(base.Object):
                        .select(Distro)
                        .where(
                                Distro.deleted_at == None,
-                               Distro.distro_id + Distro.version_id == tag,
+                               Distro.tag == tag,
                        )
                )
 
@@ -165,11 +165,7 @@ class Distro(database.Base, database.BackendMixin, database.SoftDeleteMixin):
 
        # Tag
 
-       #@property
-       #def tag(self):
-       #       return "%s%s" % (self.distro_id, self.version_id)
-
-       #tag = Column(Text, Computed(distro_id + version_id), unique=True, nullable=False)
+       tag = Column(Text, Computed(distro_id + version_id), unique=True)
 
        # Pakfire
 
index aff5276456812add19677fe374c2564380ed2895..d451a757552f4c766fd761972929d60c500ffada 100644 (file)
@@ -317,7 +317,8 @@ CREATE TABLE public.distributions (
     codename text DEFAULT ''::text NOT NULL,
     bugzilla_product text DEFAULT ''::text NOT NULL,
     bugzilla_version text DEFAULT ''::text NOT NULL,
-    deleted_at timestamp without time zone
+    deleted_at timestamp without time zone,
+    tag text GENERATED ALWAYS AS ((distro_id || version_id)) STORED
 );
 
 
@@ -1650,6 +1651,13 @@ CREATE UNIQUE INDEX builds_scratch_builds ON public.builds USING btree (id) WHER
 CREATE UNIQUE INDEX builds_uuid ON public.builds USING btree (uuid) WHERE (deleted_at IS NULL);
 
 
+--
+-- Name: distributions_tag; Type: INDEX; Schema: public; Owner: -
+--
+
+CREATE UNIQUE INDEX distributions_tag ON public.distributions USING btree (tag) WHERE (deleted_at IS NULL);
+
+
 --
 -- Name: distributions_unique; Type: INDEX; Schema: public; Owner: -
 --