cartodb/db/migrate/20150507103715_sequence_for_automated_feature_flags.rb
2020-06-15 10:58:47 +08:00

22 lines
594 B
Ruby

class SequenceForAutomatedFeatureFlags < Sequel::Migration
START_SEQ_NUMBER = -1000
NAME = 'machine_added_feature_flags_id_seq'
def up
# Create sequence to avoid trouble generating unique ids
# It starts in negative numbers and goes downward in order to be able to identify quickly flags added automatically
SequelRails.connection.run(%Q{
CREATE SEQUENCE #{NAME} INCREMENT BY -1
START WITH #{START_SEQ_NUMBER}
OWNED BY feature_flags.id;
})
end
def down
SequelRails.connection.run(%Q{
DROP SEQUENCE IF EXISTS #{NAME}
})
end
end