README.md in field_test-0.5.4 vs README.md in field_test-0.5.5

- old
+ new

@@ -330,79 +330,9 @@ ```ruby user.field_test_memberships ``` -## Upgrading - -### 0.3.0 - -Upgrade the gem and add to `config/field_test.yml`: - -```yml -legacy_participants: true -``` - -Also, if you use Field Test in emails, know that the default way participants are determined has changed. Restore the previous way with: - -```ruby -class ApplicationMailer < ActionMailer::Base - def field_test_participant - message.to.first - end -end -``` - -We also recommend upgrading participants when you have time. - -#### Upgrading Participants - -Field Test 0.3.0 splits the `field_test_memberships.participant` column into `participant_type` and `participant_id`. - -To upgrade without downtime, create a migration: - -```sh -rails generate migration upgrade_field_test_participants -``` - -with: - -```ruby -class UpgradeFieldTestParticipants < ActiveRecord::Migration[6.0] - def change - add_column :field_test_memberships, :participant_type, :string - add_column :field_test_memberships, :participant_id, :string - - add_index :field_test_memberships, [:participant_type, :participant_id, :experiment], - unique: true, name: "index_field_test_memberships_on_participant_and_experiment" - end -end -``` - -After you run it, writes will go to both the old and new sets of columns. - -Next, backfill data: - -```ruby -FieldTest::Membership.where(participant_id: nil).find_each do |membership| - participant = membership.participant - - if participant.include?(":") - participant_type, _, participant_id = participant.rpartition(":") - participant_type = nil if participant_type == "cookie" # legacy - else - participant_id = participant - end - - membership.update!( - participant_type: participant_type, - participant_id: participant_id - ) -end -``` - -Finally, remove `legacy_participants: true` from the config file. Once you confirm it’s working, you can drop the `participant` column (you can rename it first just to be extra safe). - ## Credits A huge thanks to [Evan Miller](https://www.evanmiller.org/) for deriving the Bayesian formulas. ## History