-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDatabaseCreate.sql
More file actions
114 lines (91 loc) · 2.87 KB
/
DatabaseCreate.sql
File metadata and controls
114 lines (91 loc) · 2.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
-----------------------------------------------------
-- Please replace all occurrences of <OWNER> with the user you want to be the owner of the tables
-----------------------------------------------------
-- Functions
CREATE FUNCTION public.reduce_dim(anyarray)
RETURNS SETOF anyarray AS
$function$
DECLARE
s $1%type;
BEGIN
FOREACH s SLICE 1 IN ARRAY $1 LOOP
RETURN NEXT s;
END LOOP;
RETURN;
END;
$function$
LANGUAGE plpgsql IMMUTABLE;
-- Table: public."group"
-- DROP TABLE public."group";
CREATE TABLE public."group"
(
id character varying(128) COLLATE pg_catalog."default" NOT NULL,
parent_id character varying(128) COLLATE pg_catalog."default",
priority integer NOT NULL,
deadline timestamp without time zone,
active_times jsonb,
working_days integer[],
type_flag character varying COLLATE pg_catalog."default" NOT NULL,
mode character varying COLLATE pg_catalog."default" NOT NULL,
last_index_number bigint,
parallelism_degree integer,
current_parallelism_degree integer NOT NULL DEFAULT 0,
CONSTRAINT group_pkey PRIMARY KEY (id),
CONSTRAINT parent_fk FOREIGN KEY (parent_id)
REFERENCES public."group" (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
ALTER TABLE public."group"
OWNER to <OWNER>;
-- Table: public.task
-- DROP TABLE public.task;
CREATE TABLE public.task
(
id character varying(36) COLLATE pg_catalog."default" NOT NULL,
group_id character varying(128) COLLATE pg_catalog."default" NOT NULL,
priority integer NOT NULL,
deadline timestamp without time zone,
active_times jsonb,
working_days integer[],
status character varying COLLATE pg_catalog."default" NOT NULL,
type_flag character varying COLLATE pg_catalog."default" NOT NULL,
mode character varying COLLATE pg_catalog."default" NOT NULL,
retries integer,
force boolean NOT NULL,
index_number bigint,
meta_data jsonb,
total_priority bigint,
history jsonb,
CONSTRAINT task_pkey PRIMARY KEY (id),
CONSTRAINT group_fk FOREIGN KEY (group_id)
REFERENCES public."group" (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
ALTER TABLE public.task
OWNER to <OWNER>;
-- Table: public.paused
-- DROP TABLE public.paused;
CREATE TABLE public.paused
(
id character varying(256) COLLATE pg_catalog."default" NOT NULL,
resume_date timestamp without time zone,
CONSTRAINT paused_pkey PRIMARY KEY (id)
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
ALTER TABLE public.paused
OWNER to <OWNER>;
-- Insert Default group
INSERT INTO public."group" (id, priority, type_flag, mode, parallelism_degree) VALUES ('DEFAULT_GROUP', 1, 'Batch', 'Parallel', 100);