Added first draft database schema
All checks were successful
continuous-integration/drone the build was successful
All checks were successful
continuous-integration/drone the build was successful
This commit is contained in:
parent
02fe8d2de7
commit
8de1efcd7f
3 changed files with 71 additions and 0 deletions
4
migrations/2021-06-27-131430_initial_schema/down.sql
Normal file
4
migrations/2021-06-27-131430_initial_schema/down.sql
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
-- This file should undo anything in `up.sql`
|
||||
DROP TABLE packages;
|
||||
DROP TABLE maintainers;
|
||||
DROP TYPE package_type;
|
||||
34
migrations/2021-06-27-131430_initial_schema/up.sql
Normal file
34
migrations/2021-06-27-131430_initial_schema/up.sql
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
CREATE TABLE maintainers (
|
||||
id uuid DEFAULT gen_random_uuid() PRIMARY KEY,
|
||||
|
||||
name text NOT NULL,
|
||||
email text NOT NULL,
|
||||
|
||||
UNIQUE (name, email)
|
||||
);
|
||||
|
||||
CREATE TYPE package_type AS ENUM ('deb', 'dsc', 'udeb');
|
||||
|
||||
-- Table containing information about a package
|
||||
CREATE TABLE packages (
|
||||
id uuid DEFAULT gen_random_uuid() PRIMARY KEY,
|
||||
|
||||
name text NOT NULL,
|
||||
type package_type NOT NULL,
|
||||
version text NOT NULL,
|
||||
-- This is just text, as there's no guarantee the source is present on this
|
||||
-- repository.
|
||||
source text,
|
||||
section text,
|
||||
priority text,
|
||||
-- NOTE: could this be better than just text?
|
||||
architecture text NOT NULL,
|
||||
essential boolean DEFAULT false,
|
||||
installed_size integer,
|
||||
maintainer_id uuid REFERENCES maintainers (id) NOT NULL,
|
||||
description text NOT NULL,
|
||||
homepage text,
|
||||
|
||||
-- NOTE: I don't think this is enough because architecture can be a wildcard
|
||||
UNIQUE (name, version, architecture)
|
||||
);
|
||||
Reference in a new issue