mirror of
https://github.com/Diggsey/sqlxmq.git
synced 2024-11-24 17:21:00 +00:00
05d59b0e39
Moves the migration changes introduced in 5d287b7
to separate migration
files, so existing requeuest deployments can migrate without issue.
21 lines
586 B
PL/PgSQL
21 lines
586 B
PL/PgSQL
-- Deletes all messages from a list of channel names.
|
|
CREATE FUNCTION mq_clear(channel_names TEXT[])
|
|
RETURNS VOID AS $$
|
|
BEGIN
|
|
WITH deleted_ids AS (
|
|
DELETE FROM mq_msgs WHERE channel_name = ANY(channel_names) RETURNING id
|
|
)
|
|
DELETE FROM mq_payloads WHERE id IN (SELECT id FROM deleted_ids);
|
|
END;
|
|
$$ LANGUAGE plpgsql;
|
|
|
|
-- Deletes all messages.
|
|
CREATE FUNCTION mq_clear_all()
|
|
RETURNS VOID AS $$
|
|
BEGIN
|
|
WITH deleted_ids AS (
|
|
DELETE FROM mq_msgs RETURNING id
|
|
)
|
|
DELETE FROM mq_payloads WHERE id IN (SELECT id FROM deleted_ids);
|
|
END;
|
|
$$ LANGUAGE plpgsql;
|