Merge pull request #53 from finnlabs/feature/rails3_squash_migrations
Feature/rails3 squash migrationspull/6827/head
commit
14cccdbc1a
@ -1,36 +0,0 @@ |
||||
class CreateStoriesTasksSprintsAndBurndown < ActiveRecord::Migration |
||||
def self.up |
||||
if ActiveRecord::Base.connection.table_exists? 'issues' |
||||
add_column :issues, :position, :integer |
||||
add_column :issues, :story_points, :integer |
||||
add_column :issues, :remaining_hours, :float |
||||
end |
||||
|
||||
add_column :versions, :sprint_start_date, :date, :null => true |
||||
|
||||
create_table :burndown_days do |t| |
||||
t.column :points_committed, :integer, :null => false, :default => 0 |
||||
t.column :points_accepted, :integer, :null => false, :default => 0 |
||||
t.column :points_resolved, :integer, :null => false, :default => 0 |
||||
t.column :remaining_hours, :float, :null => false, :default => 0 |
||||
|
||||
t.column :version_id, :integer, :null => false |
||||
t.timestamps |
||||
end |
||||
|
||||
add_index :burndown_days, :version_id |
||||
end |
||||
|
||||
def self.down |
||||
if ActiveRecord::Base.connection.table_exists? 'issues' |
||||
remove_column :issues, :position |
||||
remove_column :issues, :story_points |
||||
remove_column :issues, :remaining_hours |
||||
end |
||||
|
||||
remove_column :versions, :sprint_start_date |
||||
|
||||
remove_index :burndown_days, :version_id |
||||
drop_table :burndown_days |
||||
end |
||||
end |
@ -1,13 +0,0 @@ |
||||
class ChangeIssuePositionColumn < ActiveRecord::Migration |
||||
def self.up |
||||
if ActiveRecord::Base.connection.table_exists? 'issues' |
||||
change_column :issues, :position, :integer, :null => true, :default => nil |
||||
end |
||||
end |
||||
|
||||
def self.down |
||||
if ActiveRecord::Base.connection.table_exists? 'issues' |
||||
change_column :issues, :position, :integer, :null => false |
||||
end |
||||
end |
||||
end |
@ -1,17 +0,0 @@ |
||||
class CreateVersionSetting < ActiveRecord::Migration |
||||
def self.up |
||||
create_table :version_settings, :force => true do |t| |
||||
t.integer :project_id |
||||
t.integer :version_id |
||||
t.integer :display |
||||
t.timestamps |
||||
end |
||||
|
||||
add_index :version_settings, [:project_id, :version_id] |
||||
end |
||||
|
||||
def self.down |
||||
remove_index :version_settings, [:project_id, :version_id] |
||||
drop_table :version_settings |
||||
end |
||||
end |
@ -1,36 +0,0 @@ |
||||
class RemoveSprintStartDate < ActiveRecord::Migration |
||||
def self.up |
||||
Version.reset_column_information |
||||
|
||||
unless Version.column_names.include?("start_date") |
||||
raise "Abort! This migration depends on Chiliproject www.chiliproject.org/issues/279! Migrations were not executed in the correct order" |
||||
end |
||||
|
||||
Version.transaction do |
||||
Version.all.each do |version| |
||||
if version.sprint_start_date.present? and version.read_attribute(:start_date).present? and |
||||
version.sprint_start_date != version.read_attribute(:start_date) |
||||
|
||||
raise "Version #{version.id} has a start date and a sprint start date! Migrations were not executed in the correct order" |
||||
|
||||
elsif version.sprint_start_date.present? and version.read_attribute(:start_date).blank? |
||||
puts "Copying sprint_start_date to start_date for Sprint #{version.id} - #{version.name.inspect}" |
||||
version.start_date = version.sprint_start_date |
||||
version.save! |
||||
end |
||||
end |
||||
end |
||||
|
||||
remove_column(:versions, :sprint_start_date) |
||||
end |
||||
|
||||
def self.down |
||||
add_column(:versions, :sprint_start_date, :date) |
||||
|
||||
Version.reset_column_information |
||||
Version.all.each do |version| |
||||
start_date = version.read_attribute(:start_date) |
||||
version.update_attributes!(:sprint_start_date => start_date) if start_date.present? |
||||
end |
||||
end |
||||
end |
@ -1,21 +0,0 @@ |
||||
class AddProjectsIssueStatuses < ActiveRecord::Migration |
||||
def initialize |
||||
super |
||||
@issue_statuses_exists = ActiveRecord::Base.connection.tables.include? 'issue_statuses' |
||||
end |
||||
|
||||
def self.up |
||||
if @issue_statuses_exists |
||||
create_table :issue_done_statuses_for_project, :id => false do |t| |
||||
t.references :project |
||||
t.references :issue_status |
||||
end |
||||
end |
||||
end |
||||
|
||||
def self.down |
||||
if @issue_statuses_exists |
||||
drop_table :issue_done_statuses_for_project |
||||
end |
||||
end |
||||
end |
@ -1,9 +0,0 @@ |
||||
class DropBurndownDays < ActiveRecord::Migration |
||||
def self.up |
||||
drop_table :burndown_days |
||||
end |
||||
|
||||
def self.down |
||||
raise ActiveRecord::IrreversibleMigration |
||||
end |
||||
end |
@ -0,0 +1,63 @@ |
||||
require Rails.root.join("db","migrate","migration_utils","migration_squasher").to_s |
||||
require 'open_project/plugins/migration_mapping' |
||||
# This migration aggregates the migrations detailed in MIGRATION_FILES |
||||
class AggregatedBacklogsMigrations < ActiveRecord::Migration |
||||
|
||||
def initialize |
||||
super |
||||
@issues_table_exists = ActiveRecord::Base.connection.tables.include? 'issues' |
||||
end |
||||
|
||||
MIGRATION_FILES = <<-MIGRATIONS |
||||
011_create_stories_tasks_sprints_and_burndown.rb |
||||
017_change_issue_position_column.rb |
||||
20110321145023_create_version_setting.rb |
||||
20110513130147_remove_sprint_start_date.rb |
||||
20110610134000_add_projects_issue_statuses.rb |
||||
20111014073605_drop_burndown_days.rb |
||||
MIGRATIONS |
||||
|
||||
OLD_PLUGIN_NAME = "chiliproject_backlogs" |
||||
|
||||
def up |
||||
migration_names = OpenProject::Plugins::MigrationMapping.migration_files_to_migration_names(MIGRATION_FILES, OLD_PLUGIN_NAME) |
||||
Migration::MigrationSquasher.squash(migration_names) do |
||||
create_table "version_settings" do |t| |
||||
t.integer "project_id" |
||||
t.integer "version_id" |
||||
t.integer "display" |
||||
t.datetime "created_at", :null => false |
||||
t.datetime "updated_at", :null => false |
||||
end |
||||
add_index "version_settings", ["project_id", "version_id"], :name => "index_version_settings_on_project_id_and_version_id" |
||||
|
||||
create_table "issue_done_statuses_for_project", :id => false do |t| |
||||
t.integer "project_id" |
||||
t.integer "issue_status_id" |
||||
end |
||||
|
||||
if(@issues_table_exists) |
||||
change_table "issues" do |t| |
||||
t.integer "position" |
||||
t.integer "story_points" |
||||
t.float "remaining_hours" |
||||
end |
||||
end |
||||
end |
||||
end |
||||
|
||||
def down |
||||
drop_table "version_settings" |
||||
dtop_table "issue_done_statuses_for_project" |
||||
if(@issues_table_exists) |
||||
change_table "issues" do |t| |
||||
remove_column "position" |
||||
remove_column "story_points" |
||||
remove_column "remaining_hours" |
||||
end |
||||
end |
||||
end |
||||
end |
||||
|
||||
|
||||
|
@ -0,0 +1,33 @@ |
||||
#-- copyright |
||||
# OpenProject is a project management system. |
||||
# |
||||
# Copyright (C) 2012-2013 the OpenProject Team |
||||
# |
||||
# This program is free software; you can redistribute it and/or |
||||
# modify it under the terms of the GNU General Public License version 3. |
||||
# |
||||
# See doc/COPYRIGHT.rdoc for more details. |
||||
#++ |
||||
|
||||
require Rails.root.join("db","migrate","migration_utils","utils").to_s |
||||
|
||||
class LegacyIssuesBacklogsDataToWorkPackages < ActiveRecord::Migration |
||||
|
||||
def up |
||||
execute <<-SQL |
||||
UPDATE work_packages AS W |
||||
SET position = (SELECT L.position FROM legacy_issues AS L WHERE L.id = W.id), |
||||
story_points = (SELECT L.story_points FROM legacy_issues AS L WHERE L.id = W.id), |
||||
remaining_hours = (SELECT L.remaining_hours FROM legacy_issues AS L WHERE L.id = W.id) |
||||
SQL |
||||
end |
||||
|
||||
def down |
||||
execute <<-SQL |
||||
UPDATE legacy_issues AS L |
||||
SET position = (SELECT W.position FROM work_packages AS W WHERE W.id = L.id), |
||||
story_points = (SELECT W.story_points FROM work_packages AS W WHERE W.id = L.id), |
||||
remaining_hours = (SELECT W.remaining_hours FROM work_packages AS W WHERE W.id = L.id) |
||||
SQL |
||||
end |
||||
end |
@ -0,0 +1,13 @@ |
||||
class AddBacklogColumnsToWorkPackageJournal < ActiveRecord::Migration |
||||
def change |
||||
add_column :work_package_journals, :story_points, :integer |
||||
add_column :work_package_journals, :remaining_hours, :float |
||||
|
||||
add_index :work_package_journals, [:fixed_version_id, |
||||
:status_id, |
||||
:project_id, |
||||
:type_id], |
||||
:name => 'work_package_journal_on_burndown_attributes' |
||||
Journal::WorkPackageJournal.reset_column_information |
||||
end |
||||
end |
@ -1,6 +0,0 @@ |
||||
class AddBacklogColumnsToWorkPackageJournal < ActiveRecord::Migration |
||||
def change |
||||
add_column :work_package_journals, :story_points, :integer |
||||
add_column :work_package_journals, :remaining_hours, :float |
||||
end |
||||
end |
@ -1,9 +0,0 @@ |
||||
class IndexesOnWorkPackageJournalsForBurndown < ActiveRecord::Migration |
||||
def change |
||||
add_index :work_package_journals, [:fixed_version_id, |
||||
:status_id, |
||||
:project_id, |
||||
:type_id], |
||||
:name => 'work_package_journal_on_burndown_attributes' |
||||
end |
||||
end |
@ -1,19 +1,6 @@ |
||||
class RenameIssueStatusToStatus < ActiveRecord::Migration |
||||
def initialize |
||||
super |
||||
@issue_done_statuses_for_project_exists = \ |
||||
ActiveRecord::Base.connection.tables.include? 'issue_done_statuses_for_project' |
||||
end |
||||
|
||||
def change |
||||
if @issue_done_statuses_for_project_exists |
||||
rename_table :issue_done_statuses_for_project, :done_statuses_for_project |
||||
rename_column :done_statuses_for_project, :issue_status_id, :status_id |
||||
else |
||||
create_table :done_statuses_for_project, :id => false do |t| |
||||
t.references :project |
||||
t.references :status |
||||
end |
||||
end |
||||
rename_table :issue_done_statuses_for_project, :done_statuses_for_project |
||||
rename_column :done_statuses_for_project, :issue_status_id, :status_id |
||||
end |
||||
end |
||||
|
Loading…
Reference in new issue