Skip to content

Instantly share code, notes, and snippets.

@hanefi
Forked from marcocitus/Instructions
Last active July 6, 2020 10:42
Show Gist options
  • Save hanefi/3575a53f8b059b5bdc8020d938a43bc9 to your computer and use it in GitHub Desktop.
Save hanefi/3575a53f8b059b5bdc8020d938a43bc9 to your computer and use it in GitHub Desktop.
Downgrade from 9.4 to 9.3 to 9.2
-- citus--9.2-4--9.2-2
-- this is an empty downgrade path since citus--9.2-2--9.2-4.sql is empty
-- citus--9.3-2--9.2-4
-- this is a downgrade path that will revert the changes made in citus--9.2-4--9.3-2.sql
--
-- 9.3-2 added citus extension owner as a distributed object, if not already in there.
-- However we can not really know if it was a distributed owner prior to 9.3-2.
-- That's why we leave the record in place.
-- Revert the return type to void
DROP FUNCTION pg_catalog.citus_extradata_container(INTERNAL);
CREATE FUNCTION pg_catalog.citus_extradata_container(INTERNAL)
RETURNS void
LANGUAGE C
AS 'MODULE_PATHNAME', $$citus_extradata_container$$;
COMMENT ON FUNCTION pg_catalog.citus_extradata_container(INTERNAL)
IS 'placeholder function to store additional data in postgres node trees';
-- Remove newly introduced functions that are absent in earlier versions
DROP FUNCTION pg_catalog.update_distributed_table_colocation(regclass, text);
DROP FUNCTION pg_catalog.replicate_reference_tables();
DROP FUNCTION pg_catalog.citus_remote_connection_stats(
OUT hostname text,
OUT port int,
OUT database_name text,
OUT connection_count_to_node int);
DROP FUNCTION pg_catalog.worker_create_or_alter_role(
role_name text,
create_role_utility_query text,
alter_role_utility_query text);
DROP FUNCTION pg_catalog.truncate_local_data_after_distributing_table(
function_name regclass);
-- citus--9.4-1--9.3-2
-- this is a downgrade path that will revert the changes made in citus--9.3-2--9.4-1.sql
DROP FUNCTION pg_catalog.worker_last_saved_explain_analyze();
DROP FUNCTION pg_catalog.worker_save_query_explain_analyze(query text,
options jsonb);

Instructions to downgrade from v9.4.0 to 9.3.x:

  1. Install Citus v9.3.x
  2. Copy citus--9.4-1--9.3-2.sql to /share/extension/citus--9.4-1--9.3-2.sql
  3. Restart PostgreSQL
  4. Run: ALTER EXTENSION citus UPDATE;
  5. Delete /share/extension/citus--9.4-1--9.3-2.sql

Instructions to downgrade from v9.4.0 to 9.2.4:

  1. Install Citus v9.2.4
  2. Copy citus--9.4-1--9.3-2.sql and citus--9.3-2--9.2-4.sql to /share/extension/
  3. Restart PostgreSQL
  4. Run: ALTER EXTENSION citus UPDATE;
  5. Delete /share/extension/citus--9.4-1--9.3-2.sql and citus--9.3-2--9.2-4.sql

Instructions to downgrade from v9.4.0 to 9.2.0/9.2.1/9.2.2:

  1. Install Citus v9.2.x
  2. Copy citus--9.4-1--9.3-2.sql, citus--9.3-2--9.2-4.sql and citus--9.2-4--9.2-2.sql to /share/extension/
  3. Restart PostgreSQL
  4. Run: ALTER EXTENSION citus UPDATE;
  5. Delete /share/extension/citus--9.4-1--9.3-2.sql, citus--9.3-2--9.2-4.sql and citus--9.2-4--9.2-2.sql

Notes:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment