|
@@ -4,7 +4,6 @@ CREATE TABLE public.project (
|
|
ggl_id bigint,
|
|
ggl_id bigint,
|
|
description text
|
|
description text
|
|
);
|
|
);
|
|
-ALTER TABLE public.project OWNER TO postgres;
|
|
|
|
ALTER TABLE ONLY public.project
|
|
ALTER TABLE ONLY public.project
|
|
ADD CONSTRAINT description_uniq UNIQUE (description);
|
|
ADD CONSTRAINT description_uniq UNIQUE (description);
|
|
ALTER TABLE ONLY public.project
|
|
ALTER TABLE ONLY public.project
|
|
@@ -23,7 +22,6 @@ CREATE TABLE public.items (
|
|
duration interval,
|
|
duration interval,
|
|
CONSTRAINT start_end_duration_ck CHECK ((((start IS NOT NULL) AND ("end" IS NOT NULL) AND ((duration IS NULL) OR (duration = ("end" - start)))) OR ((duration IS NOT NULL) AND ((start IS NOT NULL) OR ("end" IS NOT NULL)) AND ((start IS NULL) OR ("end" IS NULL)))))
|
|
CONSTRAINT start_end_duration_ck CHECK ((((start IS NOT NULL) AND ("end" IS NOT NULL) AND ((duration IS NULL) OR (duration = ("end" - start)))) OR ((duration IS NOT NULL) AND ((start IS NOT NULL) OR ("end" IS NOT NULL)) AND ((start IS NULL) OR ("end" IS NULL)))))
|
|
);
|
|
);
|
|
-ALTER TABLE public.items OWNER TO postgres;
|
|
|
|
ALTER TABLE ONLY public.items
|
|
ALTER TABLE ONLY public.items
|
|
ADD CONSTRAINT project_id_fk FOREIGN KEY (project_id) REFERENCES public.project(id);
|
|
ADD CONSTRAINT project_id_fk FOREIGN KEY (project_id) REFERENCES public.project(id);
|
|
|
|
|
|
@@ -35,7 +33,6 @@ CREATE VIEW public.timesheet AS
|
|
FROM public.items
|
|
FROM public.items
|
|
GROUP BY ROLLUP((((COALESCE("end", (start + duration)) AT TIME ZONE 'UTC'::text))::date), project_id)
|
|
GROUP BY ROLLUP((((COALESCE("end", (start + duration)) AT TIME ZONE 'UTC'::text))::date), project_id)
|
|
ORDER BY (min(((COALESCE("end", (start + duration)) AT TIME ZONE 'UTC'::text))::date)) DESC, project_id;
|
|
ORDER BY (min(((COALESCE("end", (start + duration)) AT TIME ZONE 'UTC'::text))::date)) DESC, project_id;
|
|
-ALTER VIEW public.timesheet OWNER TO postgres;
|
|
|
|
|
|
|
|
CREATE VIEW public.today AS
|
|
CREATE VIEW public.today AS
|
|
SELECT id,
|
|
SELECT id,
|
|
@@ -45,7 +42,6 @@ CREATE VIEW public.today AS
|
|
(COALESCE("end", (start + duration)) AT TIME ZONE 'UTC'::text) AS "end"
|
|
(COALESCE("end", (start + duration)) AT TIME ZONE 'UTC'::text) AS "end"
|
|
FROM public.items
|
|
FROM public.items
|
|
WHERE (((COALESCE("end", (start + duration)) AT TIME ZONE 'UTC'::text))::date = CURRENT_DATE);
|
|
WHERE (((COALESCE("end", (start + duration)) AT TIME ZONE 'UTC'::text))::date = CURRENT_DATE);
|
|
-ALTER VIEW public.today OWNER TO postgres;
|
|
|
|
|
|
|
|
CREATE PROCEDURE public.add_item(IN p_project_id numeric, IN p_description text, IN p_start time with time zone, IN p_end time with time zone, IN p_duration interval)
|
|
CREATE PROCEDURE public.add_item(IN p_project_id numeric, IN p_description text, IN p_start time with time zone, IN p_end time with time zone, IN p_duration interval)
|
|
LANGUAGE sql
|
|
LANGUAGE sql
|
|
@@ -60,7 +56,6 @@ VALUES
|
|
WHEN TRUE AND p_start IS NULL THEN ((current_date || ' ' || p_end)::timestamp with time zone) AT TIME ZONE 'UTC' - (SELECT COALESCE("end", start + duration) FROM items ORDER BY id DESC LIMIT 1)
|
|
WHEN TRUE AND p_start IS NULL THEN ((current_date || ' ' || p_end)::timestamp with time zone) AT TIME ZONE 'UTC' - (SELECT COALESCE("end", start + duration) FROM items ORDER BY id DESC LIMIT 1)
|
|
ELSE p_duration END)
|
|
ELSE p_duration END)
|
|
$$;
|
|
$$;
|
|
-ALTER PROCEDURE public.add_item(IN p_project_id numeric, IN p_description text, IN p_start time with time zone, IN p_end time with time zone, IN p_duration interval) OWNER TO postgres;
|
|
|
|
|
|
|
|
CREATE FUNCTION public.timesheet_day(p_ago interval DEFAULT '00:00:00'::interval) RETURNS SETOF public.timesheet
|
|
CREATE FUNCTION public.timesheet_day(p_ago interval DEFAULT '00:00:00'::interval) RETURNS SETOF public.timesheet
|
|
LANGUAGE sql
|
|
LANGUAGE sql
|
|
@@ -75,4 +70,4 @@ CREATE FUNCTION public.timesheet_day(p_ago interval DEFAULT '00:00:00'::interval
|
|
GROUP BY ROLLUP (project_id)
|
|
GROUP BY ROLLUP (project_id)
|
|
ORDER BY project_id
|
|
ORDER BY project_id
|
|
$$;
|
|
$$;
|
|
-ALTER FUNCTION public.timesheet_day(p_ago interval) OWNER TO postgres;
|
|
|
|
|
|
+GRANT ALL ON SCHEMA public TO das;
|