Annotate past migrations with Rails version

Many migrations currently fail to run with:

> Directly inheriting from ActiveRecord::Migration is not supported.
> Please specify the Rails release the migration was written for:
>
>     class Example < ActiveRecord::Migration[4.2]

I've annotated those that I need to run with the Rails version at the
time each was committed:

    rake db:migrate:status \
    | grep --perl-regexp --only-matching '(?<=^  down    )\d{14}' \
    | while read -r id; do
      path="$(ls -1 db/migrate/${id}_*.rb)"
      version="$(git show "$(git log --diff-filter=A --pretty=format:%H -- "$path")":Gemfile.lock \
        | grep --perl-regexp --only-matching '(?<=^    rails \()\d+\.\d+(?=(\.\d+)+\))')"
      sed --in-place -e "s/\(< ActiveRecord::Migration\)$/\\1[$version]/" "$path"
    done
This commit is contained in:
Andrew Kvalheim 2020-05-11 12:38:36 -07:00 committed by Henne Vogelsang
parent 2051540693
commit 5a890013ef
No known key found for this signature in database
GPG key ID: 9D6164C2955FADE0
32 changed files with 32 additions and 32 deletions

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true
class CreateSurveys < ActiveRecord::Migration
class CreateSurveys < ActiveRecord::Migration[5.0]
def change
create_table :surveys do |t|
t.datetime :start_date

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true
class CreateSurveyQuestions < ActiveRecord::Migration
class CreateSurveyQuestions < ActiveRecord::Migration[5.0]
def change
create_table :survey_questions do |t|
t.references :survey

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true
class AddTargetToSurveys < ActiveRecord::Migration
class AddTargetToSurveys < ActiveRecord::Migration[5.0]
def change
add_column :surveys, :target, :integer, default: 0
end

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true
class CreateSurveyReplies < ActiveRecord::Migration
class CreateSurveyReplies < ActiveRecord::Migration[5.0]
def change
create_table :survey_replies do |t|
t.integer :survey_question_id

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true
class CreateSurveySubmissions < ActiveRecord::Migration
class CreateSurveySubmissions < ActiveRecord::Migration[5.0]
def change
create_table :survey_submissions do |t|
t.integer :user_id

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true
class AddCommentsCountToEvents < ActiveRecord::Migration
class AddCommentsCountToEvents < ActiveRecord::Migration[4.2]
def change
add_column :events, :comments_count, :integer, default: 0, null: false

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true
class AddDefaultToRevisionInConference < ActiveRecord::Migration
class AddDefaultToRevisionInConference < ActiveRecord::Migration[4.2]
def change
change_column :conferences, :revision, :integer, default: 0, null: false
end

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true
class AddEnabledToEventSchedules < ActiveRecord::Migration
class AddEnabledToEventSchedules < ActiveRecord::Migration[5.0]
def change
add_column :event_schedules, :enabled, :boolean, default: true
end

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true
class CreateBooths < ActiveRecord::Migration
class CreateBooths < ActiveRecord::Migration[4.2]
def change
create_table :booths do |t|
t.string :title

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true
class AddTypeToCfps < ActiveRecord::Migration
class AddTypeToCfps < ActiveRecord::Migration[4.2]
class TmpCfp < ActiveRecord::Base
self.table_name = 'cfps'
end

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true
class CreateBoothRequests < ActiveRecord::Migration
class CreateBoothRequests < ActiveRecord::Migration[4.2]
def change
create_table :booth_requests do |t|
t.references :booth, index: true, foreign_key: true

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true
class CreatePhysicalTickets < ActiveRecord::Migration
class CreatePhysicalTickets < ActiveRecord::Migration[4.2]
def change
create_table :physical_tickets do |t|
t.integer :ticket_purchase_id, null: false

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true
class AddShortNameToTracks < ActiveRecord::Migration
class AddShortNameToTracks < ActiveRecord::Migration[4.2]
class TmpProgram < ActiveRecord::Base
self.table_name = 'programs'
end

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true
class AddTicketLayoutToConferences < ActiveRecord::Migration
class AddTicketLayoutToConferences < ActiveRecord::Migration[4.2]
def change
add_column :conferences, :ticket_layout, :integer, default: 0
end

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true
class AddStateCfpActiveAndSubmitterReferenceToTracks < ActiveRecord::Migration
class AddStateCfpActiveAndSubmitterReferenceToTracks < ActiveRecord::Migration[4.2]
def change
add_column :tracks, :state, :string
add_column :tracks, :cfp_active, :boolean

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true
class CreateTicketScannings < ActiveRecord::Migration
class CreateTicketScannings < ActiveRecord::Migration[4.2]
def change
create_table :ticket_scannings do |t|
t.integer :physical_ticket_id, null: false

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true
class AddRoomAndDatesToTracks < ActiveRecord::Migration
class AddRoomAndDatesToTracks < ActiveRecord::Migration[4.2]
def change
add_reference :tracks, :room, index: true, foreign_key: true
add_column :tracks, :start_date, :date

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true
class MakeTrackStateNotNullAndAddDefaultValue < ActiveRecord::Migration
class MakeTrackStateNotNullAndAddDefaultValue < ActiveRecord::Migration[4.2]
class TmpTrack < ActiveRecord::Base
self.table_name = 'tracks'
end

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true
class MakeTrackCfpActiveNotNull < ActiveRecord::Migration
class MakeTrackCfpActiveNotNull < ActiveRecord::Migration[4.2]
class TmpTrack < ActiveRecord::Base
self.table_name = 'tracks'
end

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true
class AddIndexToPhysicalTickets < ActiveRecord::Migration
class AddIndexToPhysicalTickets < ActiveRecord::Migration[4.2]
def change
add_column :physical_tickets, :token, :string
add_index :physical_tickets, :token, unique: true

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true
class AddCustomDomainToConferences < ActiveRecord::Migration
class AddCustomDomainToConferences < ActiveRecord::Migration[4.2]
def change
add_column :conferences, :custom_domain, :string
end

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true
class AddRelevanceToTracks < ActiveRecord::Migration
class AddRelevanceToTracks < ActiveRecord::Migration[4.2]
def change
add_column :tracks, :relevance, :text
end

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true
class AddIncludeBoothsToSplashpages < ActiveRecord::Migration
class AddIncludeBoothsToSplashpages < ActiveRecord::Migration[4.2]
def change
add_column :splashpages, :include_booths, :boolean
end

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true
class AddBoothLimitToConferences < ActiveRecord::Migration
class AddBoothLimitToConferences < ActiveRecord::Migration[4.2]
def change
add_column :conferences, :booth_limit, :integer, default: 0
end

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true
class AddBoothsToEmailSettings < ActiveRecord::Migration
class AddBoothsToEmailSettings < ActiveRecord::Migration[4.2]
def change
add_column :email_settings, :send_on_booths_acceptance, :boolean, default: false
add_column :email_settings, :booths_acceptance_subject, :string

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true
class AddRegistrationTicketToTickets < ActiveRecord::Migration
class AddRegistrationTicketToTickets < ActiveRecord::Migration[4.2]
def change
add_column :tickets, :registration_ticket, :boolean, default: false
end

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true
class AddTrackReferenceToSchedule < ActiveRecord::Migration
class AddTrackReferenceToSchedule < ActiveRecord::Migration[4.2]
def change
add_reference :schedules, :track, index: true, foreign_key: true
end

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true
class AddSelectedScheduleToTracks < ActiveRecord::Migration
class AddSelectedScheduleToTracks < ActiveRecord::Migration[4.2]
def change
add_column :tracks, :selected_schedule_id, :integer
add_index :tracks, :selected_schedule_id

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true
class AddDescriptionToCfps < ActiveRecord::Migration
class AddDescriptionToCfps < ActiveRecord::Migration[4.2]
def change
add_column :cfps, :description, :text
end

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true
class AddAmountPaidToTicketPurchases < ActiveRecord::Migration
class AddAmountPaidToTicketPurchases < ActiveRecord::Migration[4.2]
def change
add_column :ticket_purchases, :amount_paid, :float, default: 0
end

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true
class RebuildConferencePictures < ActiveRecord::Migration
class RebuildConferencePictures < ActiveRecord::Migration[5.0]
def up
Conference.all.each do |conference|
conference.picture.recreate_versions!

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true
class AddMastodonToContact < ActiveRecord::Migration
class AddMastodonToContact < ActiveRecord::Migration[5.0]
def change
add_column :contacts, :mastodon, :string
end