From: Michael Tremer Date: Tue, 21 Jun 2022 10:19:16 +0000 (+0000) Subject: Use native UUID type for packages, builds and jobs X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d7a64543fef314fac0a1c91e111b0810f7fa950c;p=pbs.git Use native UUID type for packages, builds and jobs Signed-off-by: Michael Tremer --- diff --git a/src/buildservice/builds.py b/src/buildservice/builds.py index e2906fd3..d8909acd 100644 --- a/src/buildservice/builds.py +++ b/src/buildservice/builds.py @@ -3,7 +3,6 @@ import logging import os import re -import uuid from . import base from . import logs @@ -183,8 +182,8 @@ class Builds(base.Object): priority = -1 # Create build in database - build = self._get_build("INSERT INTO builds(uuid, pkg_id, type, distro_id, priority) \ - VALUES(%s, %s, %s, %s, %s) RETURNING *", "%s" % uuid.uuid4(), pkg.id, type, distro.id, priority) + build = self._get_build("INSERT INTO builds(pkg_id, type, distro_id, priority) \ + VALUES(%s, %s, %s, %s) RETURNING *", pkg.id, type, distro.id, priority) # Set the owner of this build if owner: diff --git a/src/buildservice/jobs.py b/src/buildservice/jobs.py index 54c1dade..38c2e5b3 100644 --- a/src/buildservice/jobs.py +++ b/src/buildservice/jobs.py @@ -5,7 +5,6 @@ import hashlib import logging import os import shutil -import uuid import pakfire import pakfire.config @@ -35,8 +34,8 @@ class Jobs(base.Object): yield Job(self.backend, row.id, data=row) def create(self, build, arch, test=False, superseeds=None): - job = self._get_job("INSERT INTO jobs(uuid, build_id, arch, test) \ - VALUES(%s, %s, %s, %s) RETURNING *", "%s" % uuid.uuid4(), build.id, arch, test) + job = self._get_job("INSERT INTO jobs(build_id, arch, test) \ + VALUES(%s, %s, %s) RETURNING *", build.id, arch, test) job.log("created") # Set cache for Build object. diff --git a/src/database.sql b/src/database.sql index 600b521d..90ba1c0c 100644 --- a/src/database.sql +++ b/src/database.sql @@ -200,7 +200,7 @@ ALTER SEQUENCE public.builders_id_seq OWNED BY public.builders.id; CREATE TABLE public.builds ( id integer NOT NULL, - uuid text NOT NULL, + uuid uuid DEFAULT gen_random_uuid() NOT NULL, pkg_id integer NOT NULL, type text DEFAULT 'release'::text NOT NULL, state text DEFAULT 'building'::text NOT NULL, @@ -394,7 +394,7 @@ ALTER SEQUENCE public.builds_id_seq OWNED BY public.builds.id; CREATE TABLE public.jobs ( id integer NOT NULL, - uuid text NOT NULL, + uuid uuid DEFAULT gen_random_uuid() NOT NULL, build_id integer NOT NULL, state text DEFAULT 'pending'::text NOT NULL, arch text NOT NULL, @@ -612,7 +612,7 @@ ALTER TABLE public.job_queue OWNER TO pakfire; CREATE TABLE public.jobs_buildroots ( job_id integer NOT NULL, - pkg_uuid text NOT NULL, + pkg_uuid uuid NOT NULL, pkg_name text NOT NULL ); @@ -978,7 +978,7 @@ CREATE TABLE public.packages ( description text NOT NULL, size bigint NOT NULL, supported_arches text, - uuid text NOT NULL, + uuid uuid NOT NULL, commit_id integer, build_id text NOT NULL, build_host text NOT NULL,