Sha256: c5da9a5a84784a65f71ce6fad8596ab24ceb94416c61349f3c5446bca92533d9
Contents?: true
Size: 1021 Bytes
Versions: 23
Compression:
Stored size: 1021 Bytes
Contents
class CreateAbsences < ActiveRecord::Migration def self.up create_table :absences do |t| t.column :user_id, :integer, :null => false, :references => [:users, :party_id] t.column :on, :date, :null => false t.column :reason, :string, :null => false end add_column :works, :started_on, :date, :null => true add_column :works, :start_time, :time, :null => true Work.find(:all).each do |w| w.started_on = (w.started_at || w.completed_at).to_date w.start_time = w.started_at && w.started_at.time_of_day w.save! end change_column_null :works, :started_on, :date, false remove_column :works, :started_at end def self.down add_column :works, :started_at, :timestamp Work.find(:all).each do |w| w.started_at = w.start_time && w.start_time.on(w.started_on) w.save! end remove_column :works, :started_on remove_column :works, :start_time drop_table :absences end class Work < ActiveRecord::Base end end
Version data entries
23 entries across 23 versions & 1 rubygems