From 87e854543f60b0fe93d59b5299b1dd3356e15407 Mon Sep 17 00:00:00 2001 From: Christian Rijke Date: Thu, 17 Oct 2013 16:45:08 +0200 Subject: [PATCH] Squash Rails 2 migrations. --- CHANGELOG.md | 2 + .../20110804151010_add_projects_overviews.rb | 27 ----------- ..._serialized_columns_from_string_to_text.rb | 35 -------------- ...5121847_create_default_my_projects_page.rb | 27 ----------- ...1_aggregated_my_project_page_migrations.rb | 46 +++++++++++++++++++ 5 files changed, 48 insertions(+), 89 deletions(-) delete mode 100644 db/migrate/20110804151010_add_projects_overviews.rb delete mode 100644 db/migrate/20111202150017_change_serialized_columns_from_string_to_text.rb delete mode 100644 db/migrate/20120605121847_create_default_my_projects_page.rb create mode 100644 db/migrate/20120605121861_aggregated_my_project_page_migrations.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index a881c64650..b28f30c344 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Changelog +* `#2451` Squash old migrations + ## 3.0.0.pre7 * `#2070` Adaptions after changing core asset locations diff --git a/db/migrate/20110804151010_add_projects_overviews.rb b/db/migrate/20110804151010_add_projects_overviews.rb deleted file mode 100644 index dea3d5c500..0000000000 --- a/db/migrate/20110804151010_add_projects_overviews.rb +++ /dev/null @@ -1,27 +0,0 @@ -#-- 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. -#++ - -class AddProjectsOverviews < ActiveRecord::Migration - def self.up - create_table :my_projects_overviews, :force => true do |t| - t.column "project_id", :integer, :default => 0, :null => false - t.column "left", :string, :default => ["wiki", "projectdetails", "issuetracking"].to_yaml, :null => false - t.column "right", :string, :default => ["members", "news"].to_yaml, :null => false - t.column "top", :string, :default => [].to_yaml, :null => false - t.column "hidden", :string, :default => [].to_yaml, :null => false - t.column "created_on", :datetime, :null => false - end - end - - def self.down - drop_table :my_projects_overviews - end -end diff --git a/db/migrate/20111202150017_change_serialized_columns_from_string_to_text.rb b/db/migrate/20111202150017_change_serialized_columns_from_string_to_text.rb deleted file mode 100644 index 7a88a26194..0000000000 --- a/db/migrate/20111202150017_change_serialized_columns_from_string_to_text.rb +++ /dev/null @@ -1,35 +0,0 @@ -#-- 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. -#++ - -class ChangeSerializedColumnsFromStringToText < ActiveRecord::Migration - def self.up - change_table :my_projects_overviews do |t| - t.change_default "left", nil - t.change_default "right", nil - t.change_default "top", nil - t.change_default "hidden", nil - - t.change "left", :text, :null => false - t.change "right", :text, :null => false - t.change "top", :text, :null => false - t.change "hidden", :text, :null => false - end - end - - def self.down - change_table :my_projects_overviews do |t| - t.change "left", :string, :default => ["wiki", "projectdetails", "issuetracking"].to_yaml, :null => false - t.change "right", :string, :default => ["members", "news"].to_yaml, :null => false - t.change "top", :string, :default => [].to_yaml, :null => false - t.change "hidden", :string, :default => [].to_yaml, :null => false - end - end -end diff --git a/db/migrate/20120605121847_create_default_my_projects_page.rb b/db/migrate/20120605121847_create_default_my_projects_page.rb deleted file mode 100644 index 7518db6190..0000000000 --- a/db/migrate/20120605121847_create_default_my_projects_page.rb +++ /dev/null @@ -1,27 +0,0 @@ -#-- 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. -#++ - -class CreateDefaultMyProjectsPage < ActiveRecord::Migration - def self.up - # creates a default my project page config for each project - # that pretty much mirrors the contents of the static page - # if there is already a my project page then don't create a second one - Project.all.each do |project| - unless MyProjectsOverview.exists? :project_id => project.id - MyProjectsOverview.create :project => project - end - end - end - - def self.down - MyProjectsOverview.destroy_all - end -end diff --git a/db/migrate/20120605121861_aggregated_my_project_page_migrations.rb b/db/migrate/20120605121861_aggregated_my_project_page_migrations.rb new file mode 100644 index 0000000000..6d75ede696 --- /dev/null +++ b/db/migrate/20120605121861_aggregated_my_project_page_migrations.rb @@ -0,0 +1,46 @@ +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 AggregatedMyProjectPageMigrations < ActiveRecord::Migration + + def initialize + super + @issues_table_exists = ActiveRecord::Base.connection.tables.include? 'issues' + end + + MIGRATION_FILES = <<-MIGRATIONS + 20110804151010_add_projects_overviews.rb + 20111202150017_change_serialized_columns_from_string_to_text.rb + 20120605121847_create_default_my_projects_page.rb + MIGRATIONS + + OLD_PLUGIN_NAME = "chiliproject_my_project_page" + + 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 :my_projects_overviews do |t| + t.integer "project_id", default: 0, null: false + t.text "left", default: ["wiki", "projectdetails", "issuetracking"].to_yaml, null: false + t.text "right", default: ["members", "news"].to_yaml, null: false + t.text "top", default: [].to_yaml, null: false + t.text "hidden", default: [].to_yaml, null: false + t.datetime "created_on", null: false + end + + # creates a default my project page config for each project + # that pretty much mirrors the contents of the static page + # if there is already a my project page then don't create a second one + Project.all.each do |project| + unless MyProjectsOverview.exists? project_id: project.id + MyProjectsOverview.create project: project + end + end + end + end + + def down + drop_table :my_projects_overviews + end +end +