mirror of
https://github.com/TracksApp/tracks.git
synced 2026-03-15 00:36:33 +01:00
Updated to svn tags/tracks-1.6
This commit is contained in:
parent
103fcb8049
commit
02496f2d44
2274 changed files with 0 additions and 0 deletions
24
db/migrate/014_convert_project_to_state_machine.rb
Normal file
24
db/migrate/014_convert_project_to_state_machine.rb
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
class ConvertProjectToStateMachine < ActiveRecord::Migration
|
||||
|
||||
class Project < ActiveRecord::Base; end
|
||||
|
||||
def self.up
|
||||
add_column :projects, :state, :string, :limit => 20, :default => "active", :null => false
|
||||
@projects = Project.find(:all)
|
||||
@projects.each do |project|
|
||||
project.state = project.done? ? 'completed' : 'active'
|
||||
project.save
|
||||
end
|
||||
remove_column :projects, :done
|
||||
end
|
||||
|
||||
def self.down
|
||||
add_column :projects, :done, :integer, :limit => 4, :default => 0, :null => false
|
||||
@projects = Project.find(:all)
|
||||
@projects.each do |project|
|
||||
project.done = project.state == 'completed'
|
||||
project.save
|
||||
end
|
||||
remove_column :projects, :state
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue