Support multiple licenses per package

Split out package licenses into two separate tables in order to support
multiple licenses per package. The code on the package details page is
adjusted accordingly.

UPGRADING contains instructions on how to convert existing licenses in
the database to the new layout.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
This commit is contained in:
Lukas Fleischer 2014-04-26 14:40:07 +02:00
parent 38eb8d2a3a
commit 9553790cfc
5 changed files with 157 additions and 16 deletions

View file

@ -126,13 +126,33 @@ CREATE TABLE Packages (
Version VARCHAR(32) NOT NULL DEFAULT '',
Description VARCHAR(255) NOT NULL DEFAULT "An Arch Package",
URL VARCHAR(255) NOT NULL DEFAULT "https://www.archlinux.org",
License VARCHAR(40) NOT NULL DEFAULT '',
PRIMARY KEY (ID),
UNIQUE (Name),
FOREIGN KEY (PackageBaseID) REFERENCES PackageBases(ID) ON DELETE CASCADE
) ENGINE = InnoDB;
-- Information about licenses
--
CREATE TABLE Licenses (
ID INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
Name VARCHAR(64) NOT NULL,
PRIMARY KEY (ID),
UNIQUE (Name)
) ENGINE = InnoDB;
-- Information about package-license-relations
--
CREATE TABLE PackageLicenses (
PackageID INTEGER UNSIGNED NOT NULL,
LicenseID INTEGER UNSIGNED NOT NULL,
PRIMARY KEY (PackageID, LicenseID),
FOREIGN KEY (PackageID) REFERENCES Packages(ID) ON DELETE CASCADE,
FOREIGN KEY (LicenseID) REFERENCES Licenses(ID) ON DELETE CASCADE
) ENGINE = InnoDB;
-- Information about groups
--
CREATE TABLE Groups (