mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2024-12-01 12:24:28 +01:00
17 lines
384 B
Ruby
17 lines
384 B
Ruby
class AddSlugToTrainings < ActiveRecord::Migration
|
|
def up
|
|
add_column :trainings, :slug, :string
|
|
add_index :trainings, :slug, unique: true
|
|
|
|
Training.all.each do |t|
|
|
slug = t.send(:set_slug) || t.slug
|
|
t.update_columns(slug: slug)
|
|
end
|
|
end
|
|
|
|
def down
|
|
remove_column :trainings, :slug, :string
|
|
remove_index :trainings, :slug, unique: true
|
|
end
|
|
end
|