13 Matching Annotations
- Mar 2022
-
-
# Optionally, you can write a description for the migration, which you can use for # documentation and changelogs. describe 'The _id suffix has been removed from the author property in the Articles API.'
-
-
github.com github.com
-
-
If you need to ensure migrations run in a certain order with regular db:migrate, set up Outrigger.ordered. It can be a hash or a proc that takes a tag; either way it needs to return a sortable value: Outrigger.ordered = { predeploy: -1, postdeploy: 1 } This will run predeploys, untagged migrations (implicitly 0), and then postdeploy migrations.
-
-
railsguides.net railsguides.net
-
The code will work without exception but it doesn’t set correct association, because the defined classes are under namespace AddStatusToUser. This is what happens in reality: role = AddStatusToUser::Role.create!(name: 'admin') AddStatusToUser::User.create!(nick: '@ka8725', role: role)
-
-
github.com github.com
-
this gem promotes writing tests for data migrations providing a way allows to write code that migrates data in separate methods.
-
having the code migrates data separately covered by proper tests eliminates those pesky situations with outdated migrations or corrupted data.
-
-
-
-
There are three keys to backfilling safely: batching, throttling, and running it outside a transaction. Use the Rails console or a separate migration with disable_ddl_transaction!.
-
Active Record creates a transaction around each migration, and backfilling in the same transaction that alters a table keeps the table locked for the duration of the backfill. class AddSomeColumnToUsers < ActiveRecord::Migration[7.0] def change add_column :users, :some_column, :text User.update_all some_column: "default_value" end end
-
-