]> git.ipfire.org Git - pbs.git/commitdiff
builds: Add a relationship to commits
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 22 Jan 2025 14:40:42 +0000 (14:40 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 22 Jan 2025 14:40:42 +0000 (14:40 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/builds.py
src/database.sql

index 57688a80533fbf4e9b6088e6a312c5d9412161fa..d75938020800289194b9820b541dbb20c303a527 100644 (file)
@@ -471,12 +471,15 @@ class Build(database.Base, database.BackendMixin, database.SoftDeleteMixin):
 
        severity = Column(Text)
 
+       # Commit ID
+
+       commit_id = Column(Integer, ForeignKey("source_commits.id"))
+
        # Commit
 
-       @lazy_property
-       def commit(self):
-               if self.pkg and self.pkg.commit:
-                       return self.pkg.commit
+       commit = sqlalchemy.orm.relationship(
+               "SourceCommit", foreign_keys=[commit_id], lazy="selectin",
+       )
 
        def has_perm(self, user):
                """
index d451a757552f4c766fd761972929d60c500ffada..de203f335baf94acefff23860c4cc58594c06acc 100644 (file)
@@ -255,7 +255,8 @@ CREATE TABLE public.builds (
     test_group_id integer,
     test boolean DEFAULT false NOT NULL,
     disable_test_builds boolean DEFAULT false NOT NULL,
-    points integer DEFAULT 0 NOT NULL
+    points integer DEFAULT 0 NOT NULL,
+    commit_id integer
 );
 
 
@@ -2077,6 +2078,14 @@ ALTER TABLE ONLY public.build_comments
     ADD CONSTRAINT builds_comments_user_id FOREIGN KEY (user_id) REFERENCES public.users(id);
 
 
+--
+-- Name: builds builds_commit_id; Type: FK CONSTRAINT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY public.builds
+    ADD CONSTRAINT builds_commit_id FOREIGN KEY (commit_id) REFERENCES public.source_commits(id) NOT VALID;
+
+
 --
 -- Name: builds builds_deleted_by; Type: FK CONSTRAINT; Schema: public; Owner: -
 --