class AddApacheAge < ActiveRecord::Migration[7.1] def up # Allow age extension execute('CREATE EXTENSION IF NOT EXISTS age;') # Load the age code execute("LOAD 'age';") # Load the ag_catalog into the search path execute('SET search_path = ag_catalog, "$user", public;') # Create age_schema graph if it doesn't exist execute("SELECT create_graph('age_schema');") end def down execute <<-SQL DO $$ BEGIN IF EXISTS ( SELECT 1 FROM pg_constraint WHERE conname = 'fk_graph_oid' ) THEN ALTER TABLE ag_catalog.ag_label DROP CONSTRAINT fk_graph_oid; END IF; END $$; SQL execute("SELECT drop_graph('age_schema', true);") execute('DROP SCHEMA IF EXISTS ag_catalog CASCADE;') execute('DROP EXTENSION IF EXISTS age;') end end