Sha256: 8f2b7fe96e564b10b873653dc1ff3b96bdb01dab849a995183a2ee9dc3fe257c

Contents?: true

Size: 863 Bytes

Versions: 47

Compression:

Stored size: 863 Bytes

Contents

class CreateBacklogs < ActiveRecord::Migration
  def self.up
    create_table :backlogs do |table|
      table.column :name,  :string, :limit => 32, :null => false
    end
    tasks_exist = Task.count > 0
    if tasks_exist
      default_backlog = Backlog.create! :name => 'Default Backlog'
      add_column :tasks, :backlog_id, :integer, :null => false, :default => default_backlog.id
      
      # TODO(uwe): This line is only needed because Rails 1.2 cannot set default to NULL
      change_column_default :tasks, :backlog_id, 0
      
      change_column_default :tasks, :backlog_id, nil
    else
      add_column :tasks, :backlog_id, :integer, :null => false
    end
  end
  
  def self.down
    remove_column :tasks, :backlog_id
    drop_table :backlogs
  end
  
  class Task < ActiveRecord::Base
  end
  
  class Backlog < ActiveRecord::Base
  end
  
end

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
backlog-0.1.2 db/migrate/002_create_backlogs.rb
backlog-0.2.0 db/migrate/002_create_backlogs.rb
backlog-0.2.1 db/migrate/002_create_backlogs.rb
backlog-0.3.0 db/migrate/002_create_backlogs.rb
backlog-0.3.2 db/migrate/002_create_backlogs.rb
backlog-0.3.1 db/migrate/002_create_backlogs.rb
backlog-0.3.3 db/migrate/002_create_backlogs.rb
backlog-0.3.4 db/migrate/002_create_backlogs.rb
backlog-0.3.5 db/migrate/002_create_backlogs.rb
backlog-0.3.6 db/migrate/002_create_backlogs.rb
backlog-0.3.8 db/migrate/002_create_backlogs.rb
backlog-0.3.7 db/migrate/002_create_backlogs.rb
backlog-0.3.9 db/migrate/002_create_backlogs.rb
backlog-0.5.0 db/migrate/002_create_backlogs.rb
backlog-0.4.0 db/migrate/002_create_backlogs.rb
backlog-0.5.1 db/migrate/002_create_backlogs.rb
backlog-0.5.10 db/migrate/002_create_backlogs.rb
backlog-0.5.2 db/migrate/002_create_backlogs.rb
backlog-0.5.3 db/migrate/002_create_backlogs.rb
backlog-0.5.4 db/migrate/002_create_backlogs.rb