]> git.ipfire.org Git - pbs.git/blobdiff - src/database.sql
db: Drop all custom types
[pbs.git] / src / database.sql
index a0c6ebfc490d18e3c3aaf7ed9ed492fa7ea8335b..c706ee6bf673406de7e9e63729eaaaf547c5162a 100644 (file)
@@ -25,204 +25,6 @@ COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
 
 SET search_path = public, pg_catalog;
 
---
--- Name: builders_history_action; Type: TYPE; Schema: public; Owner: pakfire
---
-
-CREATE TYPE builders_history_action AS ENUM (
-    'created',
-    'enabled',
-    'disabled',
-    'deleted'
-);
-
-
-ALTER TYPE builders_history_action OWNER TO pakfire;
-
---
--- Name: builds_history_action; Type: TYPE; Schema: public; Owner: pakfire
---
-
-CREATE TYPE builds_history_action AS ENUM (
-    'created',
-    'bug_added',
-    'bug_removed'
-);
-
-
-ALTER TYPE builds_history_action OWNER TO pakfire;
-
---
--- Name: builds_severity; Type: TYPE; Schema: public; Owner: pakfire
---
-
-CREATE TYPE builds_severity AS ENUM (
-    'security update',
-    'bugfix update',
-    'enhancement',
-    'new package'
-);
-
-
-ALTER TYPE builds_severity OWNER TO pakfire;
-
---
--- Name: builds_type; Type: TYPE; Schema: public; Owner: pakfire
---
-
-CREATE TYPE builds_type AS ENUM (
-    'release',
-    'scratch'
-);
-
-
-ALTER TYPE builds_type OWNER TO pakfire;
-
---
--- Name: jobs_history_action; Type: TYPE; Schema: public; Owner: pakfire
---
-
-CREATE TYPE jobs_history_action AS ENUM (
-    'created',
-    'state_change',
-    'reset',
-    'schedule_rebuild',
-    'schedule_test_job'
-);
-
-
-ALTER TYPE jobs_history_action OWNER TO pakfire;
-
---
--- Name: jobs_history_state; Type: TYPE; Schema: public; Owner: pakfire
---
-
-CREATE TYPE jobs_history_state AS ENUM (
-    'new',
-    'pending',
-    'running',
-    'finished',
-    'dispatching',
-    'uploading',
-    'failed',
-    'temporary_failed',
-    'dependency_error',
-    'aborted',
-    'download_error',
-    'deleted'
-);
-
-
-ALTER TYPE jobs_history_state OWNER TO pakfire;
-
---
--- Name: mirrors_history_action; Type: TYPE; Schema: public; Owner: pakfire
---
-
-CREATE TYPE mirrors_history_action AS ENUM (
-    'created',
-    'enabled',
-    'disabled',
-    'deleted'
-);
-
-
-ALTER TYPE mirrors_history_action OWNER TO pakfire;
-
---
--- Name: packages_deps_type; Type: TYPE; Schema: public; Owner: pakfire
---
-
-CREATE TYPE packages_deps_type AS ENUM (
-    'requires',
-    'prerequires',
-    'provides',
-    'conflicts',
-    'obsoletes',
-    'suggests',
-    'recommends'
-);
-
-
-ALTER TYPE packages_deps_type OWNER TO pakfire;
-
---
--- Name: packages_type; Type: TYPE; Schema: public; Owner: pakfire
---
-
-CREATE TYPE packages_type AS ENUM (
-    'source',
-    'binary'
-);
-
-
-ALTER TYPE packages_type OWNER TO pakfire;
-
---
--- Name: repositories_aux_status; Type: TYPE; Schema: public; Owner: pakfire
---
-
-CREATE TYPE repositories_aux_status AS ENUM (
-    'enabled',
-    'disabled'
-);
-
-
-ALTER TYPE repositories_aux_status OWNER TO pakfire;
-
---
--- Name: repositories_history_action; Type: TYPE; Schema: public; Owner: pakfire
---
-
-CREATE TYPE repositories_history_action AS ENUM (
-    'added',
-    'removed',
-    'moved'
-);
-
-
-ALTER TYPE repositories_history_action OWNER TO pakfire;
-
---
--- Name: repositories_type; Type: TYPE; Schema: public; Owner: pakfire
---
-
-CREATE TYPE repositories_type AS ENUM (
-    'testing',
-    'unstable',
-    'stable'
-);
-
-
-ALTER TYPE repositories_type OWNER TO pakfire;
-
---
--- Name: sources_commits_state; Type: TYPE; Schema: public; Owner: pakfire
---
-
-CREATE TYPE sources_commits_state AS ENUM (
-    'pending',
-    'running',
-    'finished',
-    'failed'
-);
-
-
-ALTER TYPE sources_commits_state OWNER TO pakfire;
-
---
--- Name: users_state; Type: TYPE; Schema: public; Owner: pakfire
---
-
-CREATE TYPE users_state AS ENUM (
-    'user',
-    'tester',
-    'admin'
-);
-
-
-ALTER TYPE users_state OWNER TO pakfire;
-
 --
 -- Name: on_update_current_timestamp_sources(); Type: FUNCTION; Schema: public; Owner: pakfire
 --
@@ -335,7 +137,7 @@ ALTER TABLE builders OWNER TO pakfire;
 CREATE TABLE builders_history (
     id integer NOT NULL,
     builder_id integer NOT NULL,
-    action builders_history_action NOT NULL,
+    action text NOT NULL,
     user_id integer,
     "time" timestamp without time zone NOT NULL
 );
@@ -393,9 +195,9 @@ CREATE TABLE builds (
     id integer NOT NULL,
     uuid text NOT NULL,
     pkg_id integer NOT NULL,
-    type builds_type DEFAULT 'release'::builds_type NOT NULL,
+    type text DEFAULT 'release'::text NOT NULL,
     state text DEFAULT 'building'::text NOT NULL,
-    severity builds_severity,
+    severity text,
     message text,
     time_created timestamp without time zone DEFAULT now() NOT NULL,
     update_year integer,
@@ -528,7 +330,7 @@ ALTER SEQUENCE builds_comments_id_seq OWNED BY builds_comments.id;
 CREATE TABLE builds_history (
     id integer NOT NULL,
     build_id integer NOT NULL,
-    action builds_history_action NOT NULL,
+    action text NOT NULL,
     user_id integer,
     "time" timestamp without time zone NOT NULL,
     bug_id integer
@@ -587,7 +389,7 @@ CREATE TABLE jobs (
     id integer NOT NULL,
     uuid text NOT NULL,
     build_id integer NOT NULL,
-    state text DEFAULT 'new'::text NOT NULL,
+    state text DEFAULT 'pending'::text NOT NULL,
     arch text NOT NULL,
     time_created timestamp without time zone DEFAULT now() NOT NULL,
     time_started timestamp without time zone,
@@ -597,7 +399,10 @@ CREATE TABLE jobs (
     aborted_state integer DEFAULT 0 NOT NULL,
     message text,
     test boolean DEFAULT true NOT NULL,
-    superseeded_by integer
+    superseeded_by integer,
+    dependency_check_succeeded boolean,
+    dependency_check_at timestamp without time zone,
+    CONSTRAINT jobs_states CHECK ((state = ANY (ARRAY['pending'::text, 'dispatching'::text, 'running'::text, 'uploading'::text, 'finished'::text, 'aborted'::text, 'download_error'::text, 'failed'::text])))
 );
 
 
@@ -798,8 +603,8 @@ ALTER TABLE jobs_buildroots OWNER TO pakfire;
 
 CREATE TABLE jobs_history (
     job_id integer NOT NULL,
-    action jobs_history_action NOT NULL,
-    state jobs_history_state,
+    action text NOT NULL,
+    state text,
     user_id integer,
     "time" timestamp without time zone NOT NULL,
     builder_id integer,
@@ -874,7 +679,7 @@ CREATE VIEW jobs_queue AS
             rank() OVER (ORDER BY (NOT jobs.test), builds.priority DESC, jobs.time_created) AS rank
            FROM (jobs
              LEFT JOIN builds ON ((jobs.build_id = builds.id)))
-          WHERE (jobs.state = 'pending'::text)
+          WHERE ((jobs.state = 'pending'::text) AND (jobs.dependency_check_succeeded IS TRUE))
         )
  SELECT queue.id AS job_id,
     queue.rank
@@ -1003,6 +808,41 @@ ALTER TABLE logfiles_id_seq OWNER TO pakfire;
 ALTER SEQUENCE logfiles_id_seq OWNED BY logfiles.id;
 
 
+--
+-- Name: messages; Type: TABLE; Schema: public; Owner: pakfire; Tablespace: 
+--
+
+CREATE TABLE messages (
+    id integer NOT NULL,
+    message text NOT NULL,
+    queued_at timestamp without time zone DEFAULT now() NOT NULL,
+    sent_at timestamp without time zone
+);
+
+
+ALTER TABLE messages OWNER TO pakfire;
+
+--
+-- Name: messages_id_seq; Type: SEQUENCE; Schema: public; Owner: pakfire
+--
+
+CREATE SEQUENCE messages_id_seq
+    START WITH 1
+    INCREMENT BY 1
+    NO MINVALUE
+    NO MAXVALUE
+    CACHE 1;
+
+
+ALTER TABLE messages_id_seq OWNER TO pakfire;
+
+--
+-- Name: messages_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: pakfire
+--
+
+ALTER SEQUENCE messages_id_seq OWNED BY messages.id;
+
+
 --
 -- Name: mirrors; Type: TABLE; Schema: public; Owner: pakfire; Tablespace: 
 --
@@ -1065,7 +905,7 @@ ALTER SEQUENCE mirrors_checks_id_seq OWNED BY mirrors_checks.id;
 CREATE TABLE mirrors_history (
     id integer NOT NULL,
     mirror_id integer NOT NULL,
-    action mirrors_history_action NOT NULL,
+    action text NOT NULL,
     user_id integer,
     "time" timestamp without time zone NOT NULL
 );
@@ -1125,7 +965,7 @@ CREATE TABLE packages (
     epoch integer NOT NULL,
     version text NOT NULL,
     release text NOT NULL,
-    type packages_type NOT NULL,
+    type text NOT NULL,
     arch text NOT NULL,
     groups text NOT NULL,
     maintainer text NOT NULL,
@@ -1154,7 +994,7 @@ ALTER TABLE packages OWNER TO pakfire;
 
 CREATE TABLE packages_deps (
     pkg_id integer NOT NULL,
-    type packages_deps_type NOT NULL,
+    type text NOT NULL,
     what text NOT NULL
 );
 
@@ -1273,7 +1113,7 @@ ALTER TABLE relation_sizes OWNER TO pakfire;
 CREATE TABLE repositories (
     id integer NOT NULL,
     name text NOT NULL,
-    type repositories_type DEFAULT 'testing'::repositories_type NOT NULL,
+    type text DEFAULT 'testing'::text NOT NULL,
     description text NOT NULL,
     distro_id integer NOT NULL,
     parent_id integer,
@@ -1303,7 +1143,7 @@ CREATE TABLE repositories_aux (
     description text,
     url text NOT NULL,
     distro_id integer NOT NULL,
-    status repositories_aux_status DEFAULT 'disabled'::repositories_aux_status NOT NULL
+    status text DEFAULT 'disabled'::text NOT NULL
 );
 
 
@@ -1371,7 +1211,7 @@ ALTER SEQUENCE repositories_builds_id_seq OWNED BY repositories_builds.id;
 
 CREATE TABLE repositories_history (
     build_id bigint NOT NULL,
-    action repositories_history_action NOT NULL,
+    action text NOT NULL,
     from_repo_id integer,
     to_repo_id integer,
     user_id integer,
@@ -1486,7 +1326,7 @@ CREATE TABLE sources_commits (
     subject text NOT NULL,
     body text NOT NULL,
     date timestamp without time zone NOT NULL,
-    state sources_commits_state DEFAULT 'pending'::sources_commits_state NOT NULL,
+    state text DEFAULT 'pending'::text NOT NULL,
     imported_at timestamp without time zone DEFAULT now() NOT NULL
 );
 
@@ -1577,43 +1417,6 @@ ALTER TABLE uploads_id_seq OWNER TO pakfire;
 ALTER SEQUENCE uploads_id_seq OWNED BY uploads.id;
 
 
---
--- Name: user_messages; Type: TABLE; Schema: public; Owner: pakfire; Tablespace: 
---
-
-CREATE TABLE user_messages (
-    id integer NOT NULL,
-    frm text NOT NULL,
-    "to" text NOT NULL,
-    subject text NOT NULL,
-    text text NOT NULL,
-    time_added timestamp without time zone DEFAULT now() NOT NULL
-);
-
-
-ALTER TABLE user_messages OWNER TO pakfire;
-
---
--- Name: user_messages_id_seq; Type: SEQUENCE; Schema: public; Owner: pakfire
---
-
-CREATE SEQUENCE user_messages_id_seq
-    START WITH 1
-    INCREMENT BY 1
-    NO MINVALUE
-    NO MAXVALUE
-    CACHE 1;
-
-
-ALTER TABLE user_messages_id_seq OWNER TO pakfire;
-
---
--- Name: user_messages_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: pakfire
---
-
-ALTER SEQUENCE user_messages_id_seq OWNED BY user_messages.id;
-
-
 --
 -- Name: users; Type: TABLE; Schema: public; Owner: pakfire; Tablespace: 
 --
@@ -1623,13 +1426,15 @@ CREATE TABLE users (
     name text NOT NULL,
     realname text,
     passphrase text,
-    state users_state DEFAULT 'user'::users_state NOT NULL,
+    state text DEFAULT 'user'::text NOT NULL,
     locale text,
     timezone text,
     activated boolean DEFAULT false NOT NULL,
     deleted boolean DEFAULT false NOT NULL,
     registered timestamp without time zone DEFAULT now() NOT NULL,
-    ldap_dn text
+    ldap_dn text,
+    password_recovery_code text,
+    password_recovery_code_expires_at timestamp without time zone
 );
 
 
@@ -1850,6 +1655,13 @@ ALTER TABLE ONLY keys_subkeys ALTER COLUMN id SET DEFAULT nextval('keys_subkeys_
 ALTER TABLE ONLY logfiles ALTER COLUMN id SET DEFAULT nextval('logfiles_id_seq'::regclass);
 
 
+--
+-- Name: id; Type: DEFAULT; Schema: public; Owner: pakfire
+--
+
+ALTER TABLE ONLY messages ALTER COLUMN id SET DEFAULT nextval('messages_id_seq'::regclass);
+
+
 --
 -- Name: id; Type: DEFAULT; Schema: public; Owner: pakfire
 --
@@ -1941,13 +1753,6 @@ ALTER TABLE ONLY sources_commits ALTER COLUMN id SET DEFAULT nextval('sources_co
 ALTER TABLE ONLY uploads ALTER COLUMN id SET DEFAULT nextval('uploads_id_seq'::regclass);
 
 
---
--- Name: id; Type: DEFAULT; Schema: public; Owner: pakfire
---
-
-ALTER TABLE ONLY user_messages ALTER COLUMN id SET DEFAULT nextval('user_messages_id_seq'::regclass);
-
-
 --
 -- Name: id; Type: DEFAULT; Schema: public; Owner: pakfire
 --
@@ -2237,7 +2042,7 @@ ALTER TABLE ONLY users_permissions
 -- Name: idx_2198274_primary; Type: CONSTRAINT; Schema: public; Owner: pakfire; Tablespace: 
 --
 
-ALTER TABLE ONLY user_messages
+ALTER TABLE ONLY messages
     ADD CONSTRAINT idx_2198274_primary PRIMARY KEY (id);
 
 
@@ -2281,6 +2086,14 @@ ALTER TABLE ONLY sessions
     ADD CONSTRAINT sessions_session_id_key UNIQUE (session_id);
 
 
+--
+-- Name: users_password_recovery_code; Type: CONSTRAINT; Schema: public; Owner: pakfire; Tablespace: 
+--
+
+ALTER TABLE ONLY users
+    ADD CONSTRAINT users_password_recovery_code UNIQUE (password_recovery_code);
+
+
 --
 -- Name: arches_compat_native_arch; Type: INDEX; Schema: public; Owner: pakfire; Tablespace: 
 --
@@ -2535,6 +2348,13 @@ CREATE INDEX idx_2198256_user_id ON users_emails USING btree (user_id);
 CREATE INDEX jobs_arch ON jobs USING btree (arch);
 
 
+--
+-- Name: jobs_builders_active_jobs; Type: INDEX; Schema: public; Owner: pakfire; Tablespace: 
+--
+
+CREATE INDEX jobs_builders_active_jobs ON jobs USING btree (builder_id) WHERE (state = ANY (ARRAY['dispatching'::text, 'running'::text]));
+
+
 --
 -- Name: jobs_buildroots_job_id; Type: INDEX; Schema: public; Owner: pakfire; Tablespace: 
 --
@@ -2551,6 +2371,13 @@ ALTER TABLE jobs_buildroots CLUSTER ON jobs_buildroots_job_id;
 CREATE INDEX jobs_buildroots_pkg_uuid ON jobs_buildroots USING btree (pkg_uuid);
 
 
+--
+-- Name: jobs_queue_ready; Type: INDEX; Schema: public; Owner: pakfire; Tablespace: 
+--
+
+CREATE INDEX jobs_queue_ready ON jobs USING btree (id) WHERE ((state = 'new'::text) AND (dependency_check_succeeded IS TRUE));
+
+
 --
 -- Name: jobs_time_finished; Type: INDEX; Schema: public; Owner: pakfire; Tablespace: 
 --
@@ -2565,6 +2392,13 @@ CREATE INDEX jobs_time_finished ON jobs USING btree (time_finished DESC) WHERE (
 CREATE INDEX jobs_time_started ON jobs USING btree (time_started) WHERE ((time_started IS NOT NULL) AND (time_finished IS NULL));
 
 
+--
+-- Name: messages_order; Type: INDEX; Schema: public; Owner: pakfire; Tablespace: 
+--
+
+CREATE INDEX messages_order ON messages USING btree (queued_at) WHERE (sent_at IS NULL);
+
+
 --
 -- Name: mirrors_checks_sort; Type: INDEX; Schema: public; Owner: pakfire; Tablespace: 
 --
@@ -2820,6 +2654,14 @@ ALTER TABLE ONLY jobs_repos
     ADD CONSTRAINT jobs_repos_repo_id FOREIGN KEY (repo_id) REFERENCES repositories(id);
 
 
+--
+-- Name: jobs_superseeded_by; Type: FK CONSTRAINT; Schema: public; Owner: pakfire
+--
+
+ALTER TABLE ONLY jobs
+    ADD CONSTRAINT jobs_superseeded_by FOREIGN KEY (superseeded_by) REFERENCES jobs(id);
+
+
 --
 -- Name: keys_subkeys_key_id; Type: FK CONSTRAINT; Schema: public; Owner: pakfire
 --