debian-mirror-gitlab/db/migrate/20141007100818_add_visibility_level_to_snippet.rb

25 lines
947 B
Ruby
Raw Normal View History

# rubocop:disable all
2015-04-26 12:48:37 +05:30
class AddVisibilityLevelToSnippet < ActiveRecord::Migration
2017-08-17 22:00:37 +05:30
include Gitlab::Database::MigrationHelpers
2016-06-02 11:05:42 +05:30
2015-04-26 12:48:37 +05:30
def up
add_column :snippets, :visibility_level, :integer, :default => 0, :null => false
2016-06-02 11:05:42 +05:30
execute("UPDATE snippets SET visibility_level = #{Gitlab::VisibilityLevel::PRIVATE} WHERE private = #{true_value}")
execute("UPDATE snippets SET visibility_level = #{Gitlab::VisibilityLevel::INTERNAL} WHERE private = #{false_value}")
2015-04-26 12:48:37 +05:30
add_index :snippets, :visibility_level
remove_column :snippets, :private
end
def down
add_column :snippets, :private, :boolean, :default => false, :null => false
2016-06-02 11:05:42 +05:30
execute("UPDATE snippets SET private = #{false_value} WHERE visibility_level = #{Gitlab::VisibilityLevel::INTERNAL}")
execute("UPDATE snippets SET private = #{true_value} WHERE visibility_level = #{Gitlab::VisibilityLevel::PRIVATE}")
2015-04-26 12:48:37 +05:30
remove_column :snippets, :visibility_level
end
end