$$;
+--
+-- Name: container_priority(character varying, bigint, character varying); Type: FUNCTION; Schema: public; Owner: -
+--
+
+CREATE FUNCTION public.container_priority(for_container_uuid character varying, inherited bigint, inherited_from character varying) RETURNS bigint
+ LANGUAGE sql
+ AS $$
+/* Determine the priority of an individual container.
+ The "inherited" priority comes from the path we followed from the root, the parent container
+ priority hasn't been updated in the table yet but we need to behave it like it has been.
+*/
+select coalesce(max(case when containers.uuid = inherited_from then inherited
+ when containers.priority is not NULL then containers.priority
+ else container_requests.priority * 1125899906842624::bigint - (extract(epoch from container_requests.created_at)*1000)::bigint
+ end), 0) from
+ container_requests left outer join containers on container_requests.requesting_container_uuid = containers.uuid
+ where container_requests.container_uuid = for_container_uuid and container_requests.state = 'Committed' and container_requests.priority > 0;
+$$;
+
+
+--
+-- Name: container_tree(character varying); Type: FUNCTION; Schema: public; Owner: -
+--
+
+CREATE FUNCTION public.container_tree(for_container_uuid character varying) RETURNS TABLE(pri_container_uuid character varying)
+ LANGUAGE sql
+ AS $$
+/* A lighter weight version of the update_priorities query that only returns the containers in a tree,
+ used by SELECT FOR UPDATE.
+*/
+with recursive tab(upd_container_uuid) as (
+ select for_container_uuid
+union
+ select containers.uuid
+ from (tab join container_requests on tab.upd_container_uuid = container_requests.requesting_container_uuid) as child_requests
+ join containers on child_requests.container_uuid = containers.uuid
+ where containers.state in ('Queued', 'Locked', 'Running')
+)
+select upd_container_uuid from tab;
+$$;
+
+
+--
+-- Name: container_tree_priorities(character varying); Type: FUNCTION; Schema: public; Owner: -
+--
+
+CREATE FUNCTION public.container_tree_priorities(for_container_uuid character varying) RETURNS TABLE(pri_container_uuid character varying, upd_priority bigint)
+ LANGUAGE sql
+ AS $$
+/* Calculate the priorities of all containers starting from for_container_uuid.
+ This traverses the process tree downward and calls container_priority for each container
+ and returns a table of container uuids and their new priorities.
+*/
+with recursive tab(upd_container_uuid, upd_priority) as (
+ select for_container_uuid, container_priority(for_container_uuid, 0, '')
+union
+ select containers.uuid, container_priority(containers.uuid, child_requests.upd_priority, child_requests.upd_container_uuid)
+ from (tab join container_requests on tab.upd_container_uuid = container_requests.requesting_container_uuid) as child_requests
+ join containers on child_requests.container_uuid = containers.uuid
+ where containers.state in ('Queued', 'Locked', 'Running')
+)
+select upd_container_uuid, upd_priority from tab;
+$$;
+
+
+--
+-- Name: jsonb_exists_all_inline_op(jsonb, text[]); Type: FUNCTION; Schema: public; Owner: -
+--
+
+CREATE FUNCTION public.jsonb_exists_all_inline_op(jsonb, text[]) RETURNS boolean
+ LANGUAGE sql IMMUTABLE
+ AS $_$SELECT $1 ?& $2$_$;
+
+
+--
+-- Name: jsonb_exists_inline_op(jsonb, text); Type: FUNCTION; Schema: public; Owner: -
+--
+
+CREATE FUNCTION public.jsonb_exists_inline_op(jsonb, text) RETURNS boolean
+ LANGUAGE sql IMMUTABLE
+ AS $_$SELECT $1 ? $2$_$;
+
+
--
-- Name: project_subtree_with_is_frozen(character varying, boolean); Type: FUNCTION; Schema: public; Owner: -
--
--
CREATE TABLE public.api_client_authorizations (
- id integer NOT NULL,
+ id bigint NOT NULL,
api_token character varying(255) NOT NULL,
- api_client_id integer NOT NULL,
- user_id integer NOT NULL,
+ api_client_id bigint NOT NULL,
+ user_id bigint NOT NULL,
created_by_ip_address character varying(255),
last_used_by_ip_address character varying(255),
last_used_at timestamp without time zone,
--
CREATE TABLE public.api_clients (
- id integer NOT NULL,
+ id bigint NOT NULL,
uuid character varying(255),
owner_uuid character varying(255),
modified_by_client_uuid character varying(255),
--
CREATE TABLE public.authorized_keys (
- id integer NOT NULL,
+ id bigint NOT NULL,
uuid character varying(255) NOT NULL,
owner_uuid character varying(255) NOT NULL,
modified_by_client_uuid character varying(255),
--
CREATE TABLE public.collections (
- id integer NOT NULL,
+ id bigint NOT NULL,
owner_uuid character varying(255),
created_at timestamp without time zone NOT NULL,
modified_by_client_uuid character varying(255),
--
CREATE TABLE public.container_requests (
- id integer NOT NULL,
+ id bigint NOT NULL,
uuid character varying(255),
owner_uuid character varying(255),
created_at timestamp without time zone NOT NULL,
output_ttl integer DEFAULT 0 NOT NULL,
secret_mounts jsonb DEFAULT '{}'::jsonb,
runtime_token text,
- output_storage_classes jsonb DEFAULT '["default"]'::jsonb
+ output_storage_classes jsonb DEFAULT '["default"]'::jsonb,
+ output_properties jsonb DEFAULT '{}'::jsonb,
+ cumulative_cost double precision DEFAULT 0.0 NOT NULL
);
--
CREATE TABLE public.containers (
- id integer NOT NULL,
+ id bigint NOT NULL,
uuid character varying(255),
owner_uuid character varying(255),
created_at timestamp without time zone NOT NULL,
lock_count integer DEFAULT 0 NOT NULL,
gateway_address character varying,
interactive_session_started boolean DEFAULT false NOT NULL,
- output_storage_classes jsonb DEFAULT '["default"]'::jsonb
+ output_storage_classes jsonb DEFAULT '["default"]'::jsonb,
+ output_properties jsonb DEFAULT '{}'::jsonb,
+ cost double precision DEFAULT 0.0 NOT NULL,
+ subrequests_cost double precision DEFAULT 0.0 NOT NULL
);
--
CREATE TABLE public.groups (
- id integer NOT NULL,
+ id bigint NOT NULL,
uuid character varying(255),
owner_uuid character varying(255),
created_at timestamp without time zone NOT NULL,
--
CREATE TABLE public.humans (
- id integer NOT NULL,
+ id bigint NOT NULL,
uuid character varying(255) NOT NULL,
owner_uuid character varying(255) NOT NULL,
modified_by_client_uuid character varying(255),
--
CREATE TABLE public.job_tasks (
- id integer NOT NULL,
+ id bigint NOT NULL,
uuid character varying(255),
owner_uuid character varying(255),
modified_by_client_uuid character varying(255),
--
CREATE TABLE public.jobs (
- id integer NOT NULL,
+ id bigint NOT NULL,
uuid character varying(255),
owner_uuid character varying(255),
modified_by_client_uuid character varying(255),
--
CREATE TABLE public.keep_disks (
- id integer NOT NULL,
+ id bigint NOT NULL,
uuid character varying(255) NOT NULL,
owner_uuid character varying(255) NOT NULL,
modified_by_client_uuid character varying(255),
--
CREATE TABLE public.keep_services (
- id integer NOT NULL,
+ id bigint NOT NULL,
uuid character varying(255) NOT NULL,
owner_uuid character varying(255) NOT NULL,
modified_by_client_uuid character varying(255),
--
CREATE TABLE public.links (
- id integer NOT NULL,
+ id bigint NOT NULL,
uuid character varying(255),
owner_uuid character varying(255),
created_at timestamp without time zone NOT NULL,
--
CREATE TABLE public.logs (
- id integer NOT NULL,
+ id bigint NOT NULL,
uuid character varying(255),
owner_uuid character varying(255),
modified_by_client_uuid character varying(255),
--
CREATE TABLE public.nodes (
- id integer NOT NULL,
+ id bigint NOT NULL,
uuid character varying(255),
owner_uuid character varying(255),
created_at timestamp without time zone NOT NULL,
--
CREATE TABLE public.users (
- id integer NOT NULL,
+ id bigint NOT NULL,
uuid character varying(255),
owner_uuid character varying(255) NOT NULL,
created_at timestamp without time zone NOT NULL,
--
CREATE TABLE public.pipeline_instances (
- id integer NOT NULL,
+ id bigint NOT NULL,
uuid character varying(255),
owner_uuid character varying(255),
created_at timestamp without time zone NOT NULL,
--
CREATE TABLE public.pipeline_templates (
- id integer NOT NULL,
+ id bigint NOT NULL,
uuid character varying(255),
owner_uuid character varying(255),
created_at timestamp without time zone NOT NULL,
--
CREATE TABLE public.repositories (
- id integer NOT NULL,
+ id bigint NOT NULL,
uuid character varying(255) NOT NULL,
owner_uuid character varying(255) NOT NULL,
modified_by_client_uuid character varying(255),
--
CREATE TABLE public.specimens (
- id integer NOT NULL,
+ id bigint NOT NULL,
uuid character varying(255),
owner_uuid character varying(255),
created_at timestamp without time zone NOT NULL,
--
CREATE TABLE public.traits (
- id integer NOT NULL,
+ id bigint NOT NULL,
uuid character varying(255) NOT NULL,
owner_uuid character varying(255) NOT NULL,
modified_by_client_uuid character varying(255),
--
CREATE TABLE public.virtual_machines (
- id integer NOT NULL,
+ id bigint NOT NULL,
uuid character varying(255) NOT NULL,
owner_uuid character varying(255) NOT NULL,
modified_by_client_uuid character varying(255),
--
CREATE TABLE public.workflows (
- id integer NOT NULL,
+ id bigint NOT NULL,
uuid character varying(255),
owner_uuid character varying(255),
created_at timestamp without time zone NOT NULL,
-- Name: container_requests_trgm_text_search_idx; Type: INDEX; Schema: public; Owner: -
--
-CREATE INDEX container_requests_trgm_text_search_idx ON public.container_requests USING gin (((((((((((((((((((((((((((((((((((((((((((COALESCE(uuid, ''::character varying))::text || ' '::text) || (COALESCE(owner_uuid, ''::character varying))::text) || ' '::text) || (COALESCE(modified_by_client_uuid, ''::character varying))::text) || ' '::text) || (COALESCE(modified_by_user_uuid, ''::character varying))::text) || ' '::text) || (COALESCE(name, ''::character varying))::text) || ' '::text) || COALESCE(description, ''::text)) || ' '::text) || COALESCE((properties)::text, ''::text)) || ' '::text) || (COALESCE(state, ''::character varying))::text) || ' '::text) || (COALESCE(requesting_container_uuid, ''::character varying))::text) || ' '::text) || (COALESCE(container_uuid, ''::character varying))::text) || ' '::text) || COALESCE(runtime_constraints, ''::text)) || ' '::text) || (COALESCE(container_image, ''::character varying))::text) || ' '::text) || COALESCE(environment, ''::text)) || ' '::text) || (COALESCE(cwd, ''::character varying))::text) || ' '::text) || COALESCE(command, ''::text)) || ' '::text) || (COALESCE(output_path, ''::character varying))::text) || ' '::text) || COALESCE(filters, ''::text)) || ' '::text) || COALESCE(scheduling_parameters, ''::text)) || ' '::text) || (COALESCE(output_uuid, ''::character varying))::text) || ' '::text) || (COALESCE(log_uuid, ''::character varying))::text) || ' '::text) || (COALESCE(output_name, ''::character varying))::text)) public.gin_trgm_ops);
+CREATE INDEX container_requests_trgm_text_search_idx ON public.container_requests USING gin (((((((((((((((((((((((((((((((((((((((((((((COALESCE(uuid, ''::character varying))::text || ' '::text) || (COALESCE(owner_uuid, ''::character varying))::text) || ' '::text) || (COALESCE(modified_by_client_uuid, ''::character varying))::text) || ' '::text) || (COALESCE(modified_by_user_uuid, ''::character varying))::text) || ' '::text) || (COALESCE(name, ''::character varying))::text) || ' '::text) || COALESCE(description, ''::text)) || ' '::text) || COALESCE((properties)::text, ''::text)) || ' '::text) || (COALESCE(state, ''::character varying))::text) || ' '::text) || (COALESCE(requesting_container_uuid, ''::character varying))::text) || ' '::text) || (COALESCE(container_uuid, ''::character varying))::text) || ' '::text) || COALESCE(runtime_constraints, ''::text)) || ' '::text) || (COALESCE(container_image, ''::character varying))::text) || ' '::text) || COALESCE(environment, ''::text)) || ' '::text) || (COALESCE(cwd, ''::character varying))::text) || ' '::text) || COALESCE(command, ''::text)) || ' '::text) || (COALESCE(output_path, ''::character varying))::text) || ' '::text) || COALESCE(filters, ''::text)) || ' '::text) || COALESCE(scheduling_parameters, ''::text)) || ' '::text) || (COALESCE(output_uuid, ''::character varying))::text) || ' '::text) || (COALESCE(log_uuid, ''::character varying))::text) || ' '::text) || (COALESCE(output_name, ''::character varying))::text) || ' '::text) || COALESCE((output_properties)::text, ''::text))) public.gin_trgm_ops);
--
CREATE INDEX index_collections_on_modified_at_and_uuid ON public.collections USING btree (modified_at, uuid);
+--
+-- Name: index_collections_on_name; Type: INDEX; Schema: public; Owner: -
+--
+
+CREATE INDEX index_collections_on_name ON public.collections USING gin (name public.gin_trgm_ops);
+
+
--
-- Name: index_collections_on_owner_uuid; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_groups_on_modified_at_and_uuid ON public.groups USING btree (modified_at, uuid);
+--
+-- Name: index_groups_on_name; Type: INDEX; Schema: public; Owner: -
+--
+
+CREATE INDEX index_groups_on_name ON public.groups USING gin (name public.gin_trgm_ops);
+
+
--
-- Name: index_groups_on_owner_uuid; Type: INDEX; Schema: public; Owner: -
--
('20220224203102'),
('20220301155729'),
('20220303204419'),
-('20220401153101');
+('20220401153101'),
+('20220505112900'),
+('20220726034131'),
+('20220804133317'),
+('20221219165512'),
+('20221230155924'),
+('20230421142716'),
+('20230503224107'),
+('20230815160000');