2016-06-09 08:39:16 -04:00
|
|
|
# rubocop:disable all
|
2014-10-08 09:44:25 -04:00
|
|
|
class AddVisibilityLevelToSnippet < ActiveRecord::Migration
|
2017-04-10 06:23:28 -04:00
|
|
|
include Gitlab::Database::MigrationHelpers
|
2016-04-11 00:19:09 -04:00
|
|
|
|
2014-10-08 09:44:25 -04:00
|
|
|
def up
|
|
|
|
add_column :snippets, :visibility_level, :integer, :default => 0, :null => false
|
|
|
|
|
2016-04-11 00:19:09 -04: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 09:44:25 -04: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 09:22:58 -04:00
|
|
|
|
2016-04-11 00:19:09 -04: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 09:22:58 -04:00
|
|
|
|
2014-10-08 09:44:25 -04:00
|
|
|
remove_column :snippets, :visibility_level
|
|
|
|
end
|
|
|
|
end
|