2016-04-18 23:41:39 +08:00
|
|
|
-- Table to register analysis nodes from https://github.com/cartodb/camshaft
|
|
|
|
CREATE TABLE IF NOT EXISTS
|
|
|
|
cartodb.cdb_analysis_catalog (
|
2016-07-01 18:24:44 +08:00
|
|
|
-- useful for multi account deployments
|
2016-07-01 18:13:31 +08:00
|
|
|
username text,
|
2016-04-18 23:41:39 +08:00
|
|
|
-- md5 hex hash
|
|
|
|
node_id char(40) CONSTRAINT cdb_analysis_catalog_pkey PRIMARY KEY,
|
|
|
|
-- being json allows to do queries like analysis_def->>'type' = 'buffer'
|
|
|
|
analysis_def json NOT NULL,
|
|
|
|
-- can reference other nodes in this very same table, allowing recursive queries
|
|
|
|
input_nodes char(40) ARRAY NOT NULL DEFAULT '{}',
|
|
|
|
status TEXT NOT NULL DEFAULT 'pending',
|
|
|
|
CONSTRAINT valid_status CHECK (
|
|
|
|
status IN ( 'pending', 'waiting', 'running', 'canceled', 'failed', 'ready' )
|
|
|
|
),
|
|
|
|
created_at timestamp with time zone NOT NULL DEFAULT now(),
|
|
|
|
-- should be updated when some operation was performed in the node
|
|
|
|
-- and anything associated to it might have changed
|
|
|
|
updated_at timestamp with time zone DEFAULT NULL,
|
|
|
|
-- should register last time the node was used
|
|
|
|
used_at timestamp with time zone NOT NULL DEFAULT now(),
|
|
|
|
-- should register the number of times the node was used
|
|
|
|
hits NUMERIC DEFAULT 0,
|
|
|
|
-- should register what was the last node using current node
|
2016-07-01 18:13:31 +08:00
|
|
|
last_used_from char(40),
|
2016-07-01 18:24:44 +08:00
|
|
|
-- last job modifying the node
|
2016-07-01 18:13:31 +08:00
|
|
|
last_modified_by uuid,
|
2016-07-01 18:24:44 +08:00
|
|
|
-- store error message for failures
|
2016-08-12 17:52:24 +08:00
|
|
|
last_error_message text,
|
|
|
|
-- cached tables involved in the analysis
|
|
|
|
cache_tables regclass[] NOT NULL DEFAULT '{}'
|
2016-04-18 23:41:39 +08:00
|
|
|
);
|
2016-07-01 18:13:31 +08:00
|
|
|
|
2016-07-01 18:36:07 +08:00
|
|
|
-- This can only be called from an SQL script executed by CREATE EXTENSION
|
|
|
|
DO LANGUAGE 'plpgsql' $$
|
|
|
|
BEGIN
|
|
|
|
PERFORM pg_catalog.pg_extension_config_dump('cartodb.cdb_analysis_catalog', '');
|
|
|
|
END
|
|
|
|
$$;
|
|
|
|
|
2016-07-01 18:34:40 +08:00
|
|
|
DO $$
|
2016-07-01 18:13:31 +08:00
|
|
|
BEGIN
|
|
|
|
BEGIN
|
|
|
|
ALTER TABLE cartodb.cdb_analysis_catalog ADD COLUMN username text;
|
|
|
|
EXCEPTION
|
2016-07-01 18:56:44 +08:00
|
|
|
WHEN duplicate_column THEN END;
|
2016-07-01 18:13:31 +08:00
|
|
|
END;
|
|
|
|
$$;
|
|
|
|
|
2016-07-01 18:34:40 +08:00
|
|
|
DO $$
|
2016-07-01 18:13:31 +08:00
|
|
|
BEGIN
|
|
|
|
BEGIN
|
|
|
|
ALTER TABLE cartodb.cdb_analysis_catalog ADD COLUMN last_modified_by uuid;
|
|
|
|
EXCEPTION
|
2016-07-01 18:56:44 +08:00
|
|
|
WHEN duplicate_column THEN END;
|
2016-07-01 18:13:31 +08:00
|
|
|
END;
|
|
|
|
$$;
|
|
|
|
|
2016-07-01 18:34:40 +08:00
|
|
|
DO $$
|
2016-07-01 18:13:31 +08:00
|
|
|
BEGIN
|
|
|
|
BEGIN
|
2016-07-01 18:25:05 +08:00
|
|
|
ALTER TABLE cartodb.cdb_analysis_catalog ADD COLUMN last_error_message text;
|
2016-07-01 18:13:31 +08:00
|
|
|
EXCEPTION
|
2016-07-01 18:56:44 +08:00
|
|
|
WHEN duplicate_column THEN END;
|
2016-07-01 18:13:31 +08:00
|
|
|
END;
|
|
|
|
$$;
|
2016-08-11 22:27:18 +08:00
|
|
|
|
|
|
|
DO $$
|
|
|
|
BEGIN
|
|
|
|
BEGIN
|
2016-08-12 15:42:50 +08:00
|
|
|
ALTER TABLE cartodb.cdb_analysis_catalog ADD COLUMN cache_tables regclass[] NOT NULL DEFAULT '{}';
|
2016-08-11 22:27:18 +08:00
|
|
|
EXCEPTION
|
|
|
|
WHEN duplicate_column THEN END;
|
|
|
|
END;
|
|
|
|
$$;
|