summaryrefslogtreecommitdiffstats
path: root/schema
diff options
context:
space:
mode:
Diffstat (limited to 'schema')
-rw-r--r--schema/aur-schema.sql26
-rwxr-xr-xschema/gendummydata.py27
2 files changed, 42 insertions, 11 deletions
diff --git a/schema/aur-schema.sql b/schema/aur-schema.sql
index af03b698..c98ba776 100644
--- a/schema/aur-schema.sql
+++ b/schema/aur-schema.sql
@@ -160,6 +160,32 @@ CREATE TABLE PackageDepends (
) ENGINE = InnoDB;
+-- Define the package relation types
+--
+CREATE TABLE RelationTypes (
+ ID TINYINT UNSIGNED NOT NULL AUTO_INCREMENT,
+ Name VARCHAR(32) NOT NULL DEFAULT '',
+ PRIMARY KEY (ID)
+) ENGINE = InnoDB;
+INSERT INTO RelationTypes VALUES (1, 'conflicts');
+INSERT INTO RelationTypes VALUES (2, 'provides');
+INSERT INTO RelationTypes VALUES (3, 'replaces');
+
+
+-- Track which conflicts, provides and replaces a package has
+--
+CREATE TABLE PackageRelations (
+ PackageID INTEGER UNSIGNED NOT NULL,
+ RelTypeID TINYINT UNSIGNED NOT NULL,
+ RelName VARCHAR(255) NOT NULL,
+ RelCondition VARCHAR(20),
+ INDEX (PackageID),
+ INDEX (RelName),
+ FOREIGN KEY (PackageID) REFERENCES Packages(ID) ON DELETE CASCADE,
+ FOREIGN KEY (RelTypeID) REFERENCES RelationTypes(ID) ON DELETE NO ACTION
+) ENGINE = InnoDB;
+
+
-- Track which sources a package has
--
CREATE TABLE PackageSources (
diff --git a/schema/gendummydata.py b/schema/gendummydata.py
index 18852a22..bb622d13 100755
--- a/schema/gendummydata.py
+++ b/schema/gendummydata.py
@@ -29,6 +29,7 @@ MAX_DEVS = .1 # what percentage of MAX_USERS are Developers
MAX_TUS = .2 # what percentage of MAX_USERS are Trusted Users
MAX_PKGS = 900 # how many packages to load
PKG_DEPS = (1, 15) # min/max depends a package has
+PKG_RELS = (1, 5) # min/max relations a package has
PKG_SRC = (1, 3) # min/max sources a package has
PKG_CMNTS = (1, 5) # min/max number of comments a package has
CATEGORIES_COUNT = 17 # the number of categories from aur-schema
@@ -253,18 +254,22 @@ for p in list(track_votes.keys()):
log.debug("Creating statements for package depends/sources.")
for p in list(seen_pkgs.keys()):
num_deps = random.randrange(PKG_DEPS[0], PKG_DEPS[1])
- this_deps = {}
- i = 0
- while i != num_deps:
+ for i in range(0, num_deps):
dep = random.choice([k for k in seen_pkgs])
- if dep not in this_deps:
- deptype = random.randrange(1, 5)
- if deptype == 4:
- dep += ": for " + random.choice([k for k in seen_pkgs])
- s = "INSERT INTO PackageDepends VALUES (%d, %d, '%s', NULL);\n"
- s = s % (seen_pkgs[p], deptype, dep)
- out.write(s)
- i += 1
+ deptype = random.randrange(1, 5)
+ if deptype == 4:
+ dep += ": for " + random.choice([k for k in seen_pkgs])
+ s = "INSERT INTO PackageDepends VALUES (%d, %d, '%s', NULL);\n"
+ s = s % (seen_pkgs[p], deptype, dep)
+ out.write(s)
+
+ num_rels = random.randrange(PKG_RELS[0], PKG_RELS[1])
+ for i in range(0, num_deps):
+ rel = random.choice([k for k in seen_pkgs])
+ reltype = random.randrange(1, 4)
+ s = "INSERT INTO PackageRelations VALUES (%d, %d, '%s', NULL);\n"
+ s = s % (seen_pkgs[p], reltype, rel)
+ out.write(s)
num_sources = random.randrange(PKG_SRC[0], PKG_SRC[1])
for i in range(num_sources):