From 972f47080f7e87115fa18249fe5e38424f72a516 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Wed, 22 Jan 2025 13:23:40 +0000 Subject: [PATCH] distros: Create tag as a generated column Signed-off-by: Michael Tremer --- src/buildservice/distros.py | 8 ++------ src/database.sql | 10 +++++++++- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/buildservice/distros.py b/src/buildservice/distros.py index b70b59e7..04a0415d 100644 --- a/src/buildservice/distros.py +++ b/src/buildservice/distros.py @@ -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 diff --git a/src/database.sql b/src/database.sql index aff52764..d451a757 100644 --- a/src/database.sql +++ b/src/database.sql @@ -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: - -- -- 2.47.2