diff --git a/db/migrate/20170414233856_try_step_migration_again.rb b/db/migrate/20170414233856_try_step_migration_again.rb new file mode 100644 index 0000000..78995ad --- /dev/null +++ b/db/migrate/20170414233856_try_step_migration_again.rb @@ -0,0 +1,27 @@ +class TryStepMigrationAgain < ActiveRecord::Migration[5.0] + class RecipeStub < ActiveRecord::Base + self.table_name = 'recipes' + end + + class RecipeStepStub < ActiveRecord::Base + self.table_name = 'recipe_steps' + end + + def up + RecipeStub.all.each do |r| + text = '' + RecipeStepStub.where(recipe_id: r.id).order(:sort_order).each do |s| + text << '1. ' + text << s.step + text << "\n\n" + end + + r.step_text = text + r.save! + end + end + + def down + raise ActiveRecord::IrreversibleMigration, "Can't undo step migration" + end +end diff --git a/db/schema.rb b/db/schema.rb index 679e7ce..d39c6a9 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170414185039) do +ActiveRecord::Schema.define(version: 20170414233856) do create_table "ingredient_units", force: :cascade do |t| t.integer "ingredient_id", null: false