Merge pull request #27 from finnlabs/feature/rails3_squash_migrations

Squashed old migrations
pull/6827/head
Christian Rijke 11 years ago
commit f0d719282a
  1. 2
      CHANGELOG.md
  2. 2
      README.md
  3. 37
      db/migrate/20110106210555_create_meetings.rb
  4. 37
      db/migrate/20110106221214_create_meeting_contents.rb
  5. 28
      db/migrate/20110106221946_create_meeting_content_versions.rb
  6. 38
      db/migrate/20110108230721_create_meeting_participants.rb
  7. 32
      db/migrate/20110224180804_add_lock_to_meeting_content.rb
  8. 57
      db/migrate/20110819162852_create_initial_meeting_journals.rb
  9. 73
      db/migrate/20111605171815_merge_meeting_content_versions_with_journals.rb
  10. 63
      db/migrate/20111605171865_aggregated_meeting_migrations.rb
  11. 8
      lib/open_project/meeting/engine.rb

@ -20,6 +20,8 @@ See doc/COPYRIGHT.md for more details.
# Changelog
* `#2463` Squashed old migrations
## 3.0.3
* `#1790` Adapt Meeting Plugin to the acts_as_journalized changes

@ -33,8 +33,6 @@ Afterwards, run:
This plugin contains migrations. To migrate the database, run:
`rake openproject_meeting:install:migrations`
`rake db:migrate`
Deinstallation

@ -1,37 +0,0 @@
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2011-2013 the OpenProject Foundation (OPF)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See doc/COPYRIGHT.md for more details.
#++
class CreateMeetings < ActiveRecord::Migration
def self.up
create_table :meetings do |t|
t.column :title, :string
t.column :author_id, :integer
t.column :project_id, :integer
t.column :location, :string
t.column :start_time, :datetime
t.column :duration, :float
t.timestamps
end
end
def self.down
drop_table :meetings
end
end

@ -1,37 +0,0 @@
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2011-2013 the OpenProject Foundation (OPF)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See doc/COPYRIGHT.md for more details.
#++
class CreateMeetingContents < ActiveRecord::Migration
def self.up
create_table :meeting_contents do |t|
t.column :type, :string
t.column :meeting_id, :integer
t.column :author_id, :integer
t.column :text, :text
t.column :comment, :string
t.column :version, :integer
t.timestamps
end
end
def self.down
drop_table :meeting_contents
end
end

@ -1,28 +0,0 @@
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2011-2013 the OpenProject Foundation (OPF)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See doc/COPYRIGHT.md for more details.
#++
class CreateMeetingContentVersions < ActiveRecord::Migration
def self.up
MeetingContent.create_versioned_table
end
def self.down
MeetingContent.drop_versioned_table
end
end

@ -1,38 +0,0 @@
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2011-2013 the OpenProject Foundation (OPF)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See doc/COPYRIGHT.md for more details.
#++
class CreateMeetingParticipants < ActiveRecord::Migration
def self.up
create_table :meeting_participants do |t|
t.column :user_id, :integer
t.column :meeting_id, :integer
t.column :meeting_role_id, :integer
t.column :email, :string
t.column :name, :string
t.column :invited, :boolean
t.column :attended, :boolean
t.timestamps
end
end
def self.down
drop_table :meeting_participants
end
end

@ -1,32 +0,0 @@
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2011-2013 the OpenProject Foundation (OPF)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See doc/COPYRIGHT.md for more details.
#++
class AddLockToMeetingContent < ActiveRecord::Migration
def self.up
add_column :meeting_contents, :locked, :boolean, :default => false
# Check for existence of the pre-journalized MeetingContentVersions table
add_column :meeting_content_versions, :locked, :boolean, :default => nil if table_exists? :meeting_content_versions
end
def self.down
remove_column :meeting_contents, :locked
# Check for existence of the pre-journalized MeetingContentVersions table
remove_column :meeting_content_versions, :locked if table_exists? :meeting_content_versions
end
end

@ -1,57 +0,0 @@
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2011-2013 the OpenProject Foundation (OPF)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See doc/COPYRIGHT.md for more details.
#++
class CreateInitialMeetingJournals < ActiveRecord::Migration
def self.up
[Meeting].each do |p|
say_with_time("Building initial journals for #{p.class_name}") do
# avoid touching the journaled object on journal creation
p.journal_class.class_exec {
def touch_journaled_after_creation
end
}
activity_type = p.activity_provider_options.keys.first
# Create initial journals
p.find(:all).each do |o|
# Using rescue and save! here because either the Journal or the
# touched record could fail. This will catch either error and continue
begin
new_journal = o.recreate_initial_journal!
rescue ActiveRecord::RecordInvalid => ex
if new_journal.errors.count == 1 && new_journal.errors.first[0] == "version"
# Skip, only error was from creating the initial journal for a record that already had one.
else
puts "ERROR: errors creating the initial journal for #{o.class.to_s}##{o.id.to_s}:"
puts " #{ex.message}"
end
end
end
end
end
end
def self.down
# no-op
# (well, in theory we should delete the MeetingJournals…)
end
end

@ -1,73 +0,0 @@
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2011-2013 the OpenProject Foundation (OPF)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See doc/COPYRIGHT.md for more details.
#++
class MergeMeetingContentVersionsWithJournals < ActiveRecord::Migration
def self.up
# The table doesn't exist on fresh installations
if table_exists? :meeting_content_versions
# This is provided here for migrating up after the MeetingContent::Version class has been removed
unless MeetingContent.const_defined?("Version")
MeetingContent.const_set("Version", Class.new(ActiveRecord::Base))
end
# load some classes
MeetingAgenda
MeetingMinutes
# avoid touching WikiContent on journal creation
MeetingAgendaJournal.class_exec {
def touch_journaled_after_creation
end
}
MeetingMinutesJournal.class_exec {
def touch_journaled_after_creation
end
}
cache = Hash.new{|h,k| h[k] = Hash.new{|h,k| h[k] = Hash.new{|h,k| h[k] = {}}}}
MeetingContent::Version.find_by_sql('SELECT * FROM meeting_content_versions ORDER BY version ASC').each do |mcv|
options = {:journaled_id => mcv.meeting_content_id, :created_at => mcv.created_at,
:user_id => mcv.author_id, :notes => mcv.comment, :activity_type => 'meetings',
:version => mcv.version}
ft = [cache[mcv.meeting_content_id][mcv.versioned_type][mcv.version-1][:locked], mcv.locked]
options[:changes] = {'locked' => ft} unless mcv.version == 1 || ft.first == ft.last
journal = case mcv.versioned_type
when 'MeetingAgenda'
MeetingAgendaJournal.create! options
when 'MeetingMinutes'
MeetingMinutesJournal.create! options
end
journal.text = mcv.text unless mcv.text == cache[mcv.meeting_content_id][mcv.versioned_type][mcv.version-1][:text]
cache[mcv.meeting_content_id][mcv.versioned_type][mcv.version] = {:text => mcv.text, :locked => mcv.locked}
end
drop_table :meeting_content_versions
end
change_table :meeting_contents do |t|
t.rename :version, :lock_version
t.remove :comment
end
end
def self.down
raise ActiveRecord::IrreversibleMigration, "Can't revert to pre-journalized versioning model"
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 AggregatedImpermanentMembershipsMigrations < ActiveRecord::Migration
MIGRATION_FILES = <<-MIGRATIONS
20110106210555_create_meetings.rb
20110106221214_create_meeting_contents.rb
20110106221946_create_meeting_content_versions.rb
20110108230721_create_meeting_participants.rb
20110224180804_add_lock_to_meeting_content.rb
20110819162852_create_initial_meeting_journals.rb
20111605171815_merge_meeting_content_versions_with_journals.rb
MIGRATIONS
OLD_PLUGIN_NAME = "redmine_meeting"
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 "meeting_contents" do |t|
t.string "type"
t.integer "meeting_id"
t.integer "author_id"
t.text "text"
t.integer "lock_version"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.boolean "locked", :default => false
end
create_table "meeting_participants" do |t|
t.integer "user_id"
t.integer "meeting_id"
t.integer "meeting_role_id"
t.string "email"
t.string "name"
t.boolean "invited"
t.boolean "attended"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "meetings" do |t|
t.string "title"
t.integer "author_id"
t.integer "project_id"
t.string "location"
t.datetime "start_time"
t.float "duration"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
end
end
def down
drop_table "meeting_contents"
drop_table "meeting_participants"
drop_table "meetings"
end
end

@ -68,6 +68,14 @@ module OpenProject::Meeting
app.config.plugins_to_test_paths << self.root
end
initializer :append_migrations do |app|
unless app.root.to_s.match root.to_s
config.paths["db/migrate"].expanded.each do |expanded_path|
app.config.paths["db/migrate"] << expanded_path
end
end
end
config.before_configuration do |app|
# This is required for the routes to be loaded first
# as the routes should be prepended so they take precedence over the core.

Loading…
Cancel
Save