Squashed old migrations

pull/6827/head
Sebastian Schuster 11 years ago
parent f36ebfd46c
commit d043618aa1
  1. 2
      CHANGELOG.md
  2. 34
      db/migrate/001_sti_for_roles.rb
  3. 43
      db/migrate/20100528100562_aggegated_global_roles_migrations.rb

@ -1,5 +1,7 @@
# Changelog
* `#2459` Squashed old migrations
## 1.0.1.pre1
* `#1797` Adaptions to Migration of DTAG Customizing

@ -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

@ -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
Loading…
Cancel
Save