1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-11-29 10:24:20 +01:00
fab-manager/db/migrate/20150107103903_add_slug_to_trainings.rb

19 lines
405 B
Ruby
Raw Normal View History

# frozen_string_literal:true
class AddSlugToTrainings < ActiveRecord::Migration[4.2]
2016-03-23 18:39:41 +01:00
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
2016-03-23 18:39:41 +01:00
end
end