2016-06-09 12:39:16 +00:00
|
|
|
# rubocop:disable all
|
2014-10-08 13:44:25 +00:00
|
|
|
class AddVisibilityLevelToSnippet < ActiveRecord::Migration
|
2016-04-11 04:19:09 +00:00
|
|
|
include Gitlab::Database
|
|
|
|
|
2014-10-08 13:44:25 +00:00
|
|
|
def up
|
|
|
|
add_column :snippets, :visibility_level, :integer, :default => 0, :null => false
|
|
|
|
|
2016-04-11 04:19:09 +00:00
|
|
|
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}")
|
2014-10-08 13:44:25 +00:00
|
|
|
|
|
|
|
add_index :snippets, :visibility_level
|
|
|
|
|
|
|
|
remove_column :snippets, :private
|
|
|
|
end
|
|
|
|
|
|
|
|
def down
|
|
|
|
add_column :snippets, :private, :boolean, :default => false, :null => false
|
2016-04-10 13:22:58 +00:00
|
|
|
|
2016-04-11 04:19:09 +00:00
|
|
|
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}")
|
2016-04-10 13:22:58 +00:00
|
|
|
|
2014-10-08 13:44:25 +00:00
|
|
|
remove_column :snippets, :visibility_level
|
|
|
|
end
|
|
|
|
end
|