Commit 3c9b21b0 authored by Arturo Herrero's avatar Arturo Herrero Committed by Adam Hegyi

Update example in Migration Style guide

- Remove unnecessary mixing with migration helper methods.
- Passing a hash containing `:from` and `:to` will make this change
reversible in migration.
parent f1dd8af7
...@@ -424,16 +424,10 @@ Take the following migration as an example: ...@@ -424,16 +424,10 @@ Take the following migration as an example:
```ruby ```ruby
class DefaultRequestAccessGroups < ActiveRecord::Migration[5.2] class DefaultRequestAccessGroups < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false DOWNTIME = false
def up def change
change_column_default :namespaces, :request_access_enabled, true change_column_default(:namespaces, :request_access_enabled, from: false, to: true)
end
def down
change_column_default :namespaces, :request_access_enabled, false
end end
end end
``` ```
......
# frozen_string_literal: true # frozen_string_literal: true
# See http://doc.gitlab.com/ce/development/migration_style_guide.html # See https://docs.gitlab.com/ee/development/migration_style_guide.html
# for more information on how to write migrations for GitLab. # for more information on how to write migrations for GitLab.
class <%= migration_class_name %> < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>] class <%= migration_class_name %> < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
......
# frozen_string_literal: true # frozen_string_literal: true
# See http://doc.gitlab.com/ce/development/migration_style_guide.html # See https://docs.gitlab.com/ee/development/migration_style_guide.html
# for more information on how to write migrations for GitLab. # for more information on how to write migrations for GitLab.
class <%= migration_class_name %> < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>] class <%= migration_class_name %> < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
......
# frozen_string_literal: true # frozen_string_literal: true
# See http://doc.gitlab.com/ce/development/migration_style_guide.html # See https://docs.gitlab.com/ee/development/migration_style_guide.html
# for more information on how to write migrations for GitLab. # for more information on how to write migrations for GitLab.
class <%= migration_class_name %> < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>] class <%= migration_class_name %> < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment