mirror of
https://github.com/iritmaximus/brewery.git
synced 2026-10-12 19:13:49 +03:00
fix: added desc field to styles
This commit is contained in:
@@ -3,6 +3,7 @@ class CreateStyles < ActiveRecord::Migration[7.0]
|
||||
create_table :styles do |t|
|
||||
t.index :id
|
||||
t.text :name
|
||||
t.text :description
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
@@ -33,20 +34,19 @@ class CreateStyles < ActiveRecord::Migration[7.0]
|
||||
end
|
||||
|
||||
def self.down
|
||||
add_column :beers, :style, :text
|
||||
add_column :beers, :style_name, :text
|
||||
|
||||
Beer.all.each do |beer|
|
||||
style = Style.find_by id: beer.style_id
|
||||
if style.nil?
|
||||
Beer.update beer.id, { :style => "IPA" }
|
||||
Beer.update beer.id, { :style_name => "IPA" }
|
||||
else
|
||||
Beer.update beer.id, { :style => style.name }
|
||||
Beer.update beer.id, { :style_name => style.name }
|
||||
end
|
||||
end
|
||||
|
||||
remove_column :beers, :style_id
|
||||
remove_column :beers, :old_style
|
||||
|
||||
rename_column :beers, :style_name, :style
|
||||
drop_table :styles
|
||||
end
|
||||
end
|
||||
|
||||
Generated
+1
@@ -52,6 +52,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_11_20_133953) do
|
||||
|
||||
create_table "styles", force: :cascade do |t|
|
||||
t.text "name"
|
||||
t.text "description"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["id"], name: "index_styles_on_id"
|
||||
|
||||
Reference in New Issue
Block a user