]> git.ipfire.org Git - pbs.git/commitdiff
distros: Implement creating new distros
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 12 Oct 2022 14:24:46 +0000 (14:24 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 12 Oct 2022 14:24:46 +0000 (14:24 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/distribution.py
src/database.sql

index 13417199e2175f53cac7a9fbb6214fc822004071..d48410f0e768b9d5e00af33a789a72757bdc581a 100644 (file)
@@ -4,6 +4,7 @@ import logging
 import pakfire
 
 from . import base
+from . import misc
 from . import packages
 from . import sources
 from .decorators import *
@@ -37,6 +38,23 @@ class Distributions(base.Object):
                return self._get_distribution("SELECT * FROM distributions \
                        WHERE slug = %s AND deleted IS FALSE", slug)
 
+       def create(self, name, tag):
+               slug = misc.normalize(name)
+
+               # Insert into the database
+               return self._get_distribution("""
+                       INSERT INTO
+                               distributions(
+                                       name, slug, tag
+                               )
+                       VALUES(
+                               %s, %s, %s
+                       )
+                       RETURNING
+                               *""",
+                       name, slug, tag,
+               )
+
 
 class Distribution(base.DataObject):
        table = "distributions"
index 74920049cf976856c5ca48bddcbd79a263bade71..9e5eb7a571ad7792779ae0ec12efec2fd13e174b 100644 (file)
@@ -341,10 +341,10 @@ CREATE TABLE public.distributions (
     id integer NOT NULL,
     name text NOT NULL,
     slug text NOT NULL,
-    slogan text NOT NULL,
-    description text,
-    vendor text NOT NULL,
-    contact text,
+    slogan text DEFAULT ''::text NOT NULL,
+    description text DEFAULT ''::text NOT NULL,
+    vendor text DEFAULT ''::text NOT NULL,
+    contact text DEFAULT ''::text NOT NULL,
     tag text NOT NULL,
     deleted boolean DEFAULT false NOT NULL,
     arches text[] DEFAULT ARRAY[]::text[] NOT NULL,