From d043618aa1ea37635e8a7d445d9fbe95bf65ca08 Mon Sep 17 00:00:00 2001 From: Sebastian Schuster Date: Thu, 17 Oct 2013 18:54:39 +0200 Subject: [PATCH] Squashed old migrations --- CHANGELOG.md | 2 + db/migrate/001_sti_for_roles.rb | 34 --------------- ...00562_aggegated_global_roles_migrations.rb | 43 +++++++++++++++++++ 3 files changed, 45 insertions(+), 34 deletions(-) delete mode 100644 db/migrate/001_sti_for_roles.rb create mode 100644 db/migrate/20100528100562_aggegated_global_roles_migrations.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index 170702c6a6..ff5b43b0b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Changelog +* `#2459` Squashed old migrations + ## 1.0.1.pre1 * `#1797` Adaptions to Migration of DTAG Customizing diff --git a/db/migrate/001_sti_for_roles.rb b/db/migrate/001_sti_for_roles.rb deleted file mode 100644 index 96ab4bb5d9..0000000000 --- a/db/migrate/001_sti_for_roles.rb +++ /dev/null @@ -1,34 +0,0 @@ -#-- copyright -# OpenProject is a project management system. -# -# Copyright (C) 2010-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 StiForRoles < ActiveRecord::Migration - def self.up - add_column :roles, :type, :string, :limit => 30, :default => "Role" - - ActiveRecord::Base.connection.execute("UPDATE roles SET type='Role';") - - create_table :principal_roles, :force => true do |t| - t.column :role_id, :integer, :null => false - t.column :principal_id, :integer, :null => false - t.timestamps - end - - add_index :principal_roles, :role_id - add_index :principal_roles, :principal_id - end - - def self.down - remove_column :roles, :type - remove_index :principal_roles, :role_id - remove_index :principal_roles, :principal_id - drop_table :principal_roles - end -end \ No newline at end of file diff --git a/db/migrate/20100528100562_aggegated_global_roles_migrations.rb b/db/migrate/20100528100562_aggegated_global_roles_migrations.rb new file mode 100644 index 0000000000..2db0bd3c05 --- /dev/null +++ b/db/migrate/20100528100562_aggegated_global_roles_migrations.rb @@ -0,0 +1,43 @@ +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 AggregatedGlobalRolesMigrations < ActiveRecord::Migration + + + MIGRATION_FILES = <<-MIGRATIONS + 001_sti_for_roles.rb + MIGRATIONS + + OLD_PLUGIN_NAME = "redmine_global_roles" + + def up + migration_names = OpenProject::Plugins::MigrationMapping.migration_files_to_migration_names(MIGRATION_FILES, OLD_PLUGIN_NAME) + Migration::MigrationSquasher.squash(migration_names) do + add_column :roles, :type, :string, :limit => 30, :default => "Role" + + ActiveRecord::Base.connection.execute("UPDATE roles SET type='Role';") + + Role.reset_column_information + + create_table :principal_roles do |t| + t.column :role_id, :integer, :null => false + t.column :principal_id, :integer, :null => false + t.timestamps + end + + add_index :principal_roles, :role_id + add_index :principal_roles, :principal_id + end + end + + def down + remove_column :roles, :type + remove_index :principal_roles, :role_id + remove_index :principal_roles, :principal_id + drop_table :principal_roles + Role.reset_column_information + end +end + + +