Comment up the sql file
The plugin-work-queue provides a SQS-like queue abstraction over Postgresql.
-## Queue Schema
-```postgresql
-CREATE SCHEMA plugin_work_queue;
-
-CREATE TYPE plugin_work_queue.status AS ENUM ('enqueued', 'failed', 'processed');
-
-CREATE FUNCTION plugin_work_queue.megabytes(bytes integer) RETURNS integer AS
-$$
-BEGIN
- RETURN bytes * 1000 * 1000;
-END;
-$$ LANGUAGE plpgsql;
-
-CREATE TABLE IF NOT EXISTS plugin_work_queue.generator_plugin_executions
-(
- execution_key bigserial NOT NULL,
- tenant_id uuid NOT NULL,
- plugin_id uuid NOT NULL,
- pipeline_message bytea NOT NULL,
- current_status plugin_work_queue.status NOT NULL,
- creation_time timestamptz NOT NULL,
- last_updated timestamptz NOT NULL,
- visible_after timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP,
- try_count integer NOT NULL,
- CHECK (length(pipeline_message) < plugin_work_queue.megabytes(256)),
- CHECK (last_updated >= creation_time)
-)
- PARTITION BY RANGE (creation_time);
-
-CREATE TABLE IF NOT EXISTS plugin_work_queue.analyzer_plugin_executions
-(
- execution_key bigserial NOT NULL,
- tenant_id uuid NOT NULL,
- plugin_id uuid NOT NULL,
- pipeline_message bytea NOT NULL,
- current_status plugin_work_queue.status NOT NULL,
- creation_time timestamptz NOT NULL,
- last_updated timestamptz NOT NULL,
- visible_after timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP,
- try_count integer NOT NULL,
- CHECK (length(pipeline_message) < plugin_work_queue.megabytes(256)),
- CHECK (last_updated >= creation_time)
-)
- PARTITION BY RANGE (creation_time);
-
-CREATE INDEX IF NOT EXISTS execution_key_ix ON plugin_work_queue.generator_plugin_executions (execution_key);
-CREATE INDEX IF NOT EXISTS creation_time_ix ON plugin_work_queue.generator_plugin_executions (creation_time);
-
-CREATE INDEX IF NOT EXISTS execution_key_ix ON plugin_work_queue.analyzer_plugin_executions (execution_key);
-CREATE INDEX IF NOT EXISTS creation_time_ix ON plugin_work_queue.analyzer_plugin_executions (creation_time);
-```
-
-`execution_key` is a `bigserial` - an auto-incrementing 64bit integer.
-
-`plugin_id` is the uuid name of the plugin to send this execution result to.
-
-`pipeline_message` is the raw bytes to be interpreted by the plugin. The message is limited to 256MB as an arbitrary but
-reasonable upper limit.
-
-`current_status` is an enum representing the state. 'enqueued' is the default, and a message will be set to either 'processed' or 'failed' based on its success.
-
-`creation_time` is when the row was created.
-
-`last_updated` is set with each update to the row
-
-`visible_after` is essentially a visibility timeout. A `visible_after` of NULL means a message is available, which
-is the default state. Every time a message is SELECT'd we update `visible_after`. See the `Visibility Timeout` section
-below.
-
-`try_count` on every receive we increment `try_count` to indicate another attempt to process this message
-
## Algorithm
The query for processing a message is:
