Revert "Index and form for bit preferences"

This commit is contained in:
Albert Yi
2016-09-23 16:21:09 -07:00
committed by GitHub
parent 7451e6fe47
commit c776fb478a
3 changed files with 14 additions and 53 deletions

View File

@@ -1,24 +0,0 @@
class AddIndexToUsersBitPrefs < ActiveRecord::Migration
def up
execute "set statement_timeout = 0"
execute <<-'SQL'
CREATE OR REPLACE FUNCTION bit_position_array(x bigint)
RETURNS integer[] AS $BODY$
select array_agg(i)
from generate_series(0, floor(log(2, x))::integer) i
where (x & (1::bigint << i)) > 0;
$BODY$ LANGUAGE sql IMMUTABLE
SQL
execute <<-'SQL'
CREATE INDEX index_users_on_bit_prefs_array
ON users USING gin (bit_position_array(bit_prefs) _int4_ops)
SQL
end
def down
execute "set statement_timeout = 0"
execute "DROP INDEX index_users_on_bit_prefs_array"
execute "DROP FUNCTION bit_position_array(x bigint)"
end
end