13 Matching Annotations
  1. Mar 2022
    1. # 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.'
    1. 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.
    1. 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)
    1. this gem promotes writing tests for data migrations providing a way allows to write code that migrates data in separate methods.
    2. having the code migrates data separately covered by proper tests eliminates those pesky situations with outdated migrations or corrupted data.
    1. 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!.
    2. 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