cartodb-4.42/db/migrate/20150507103715_sequence_for_automated_feature_flags.rb

22 lines
594 B
Ruby
Raw Normal View History

2024-04-06 13:25:13 +08:00
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