mirror of
https://github.com/Diggsey/sqlxmq.git
synced 2024-11-21 15:51:00 +00:00
Move migration changes to separate files
Moves the migration changes introduced in 5d287b7
to separate migration
files, so existing requeuest deployments can migrate without issue.
This commit is contained in:
parent
9424605cfb
commit
05d59b0e39
8 changed files with 46 additions and 46 deletions
|
@ -1,5 +1,3 @@
|
|||
DROP FUNCTION mq_clear;
|
||||
DROP FUNCTION mq_clear_all;
|
||||
DROP FUNCTION mq_checkpoint;
|
||||
DROP FUNCTION mq_keep_alive;
|
||||
DROP FUNCTION mq_delete;
|
||||
|
|
|
@ -287,24 +287,3 @@ RETURNS VOID AS $$
|
|||
id = msg_id;
|
||||
$$ LANGUAGE SQL;
|
||||
|
||||
-- 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;
|
||||
|
|
2
migrations/20210921115907_clear.down.sql
Normal file
2
migrations/20210921115907_clear.down.sql
Normal file
|
@ -0,0 +1,2 @@
|
|||
DROP FUNCTION mq_clear;
|
||||
DROP FUNCTION mq_clear_all;
|
21
migrations/20210921115907_clear.up.sql
Normal file
21
migrations/20210921115907_clear.up.sql
Normal file
|
@ -0,0 +1,21 @@
|
|||
-- 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;
|
|
@ -1,5 +1,3 @@
|
|||
DROP FUNCTION mq_clear;
|
||||
DROP FUNCTION mq_clear_all;
|
||||
DROP FUNCTION mq_checkpoint;
|
||||
DROP FUNCTION mq_keep_alive;
|
||||
DROP FUNCTION mq_delete;
|
||||
|
|
|
@ -287,24 +287,3 @@ RETURNS VOID AS $$
|
|||
id = msg_id;
|
||||
$$ LANGUAGE SQL;
|
||||
|
||||
-- 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;
|
||||
|
|
2
sqlxmq_stress/migrations/20210921115907_clear.down.sql
Normal file
2
sqlxmq_stress/migrations/20210921115907_clear.down.sql
Normal file
|
@ -0,0 +1,2 @@
|
|||
DROP FUNCTION mq_clear;
|
||||
DROP FUNCTION mq_clear_all;
|
21
sqlxmq_stress/migrations/20210921115907_clear.up.sql
Normal file
21
sqlxmq_stress/migrations/20210921115907_clear.up.sql
Normal file
|
@ -0,0 +1,21 @@
|
|||
-- 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;
|
Loading…
Reference in a new issue