mirror of
https://github.com/redmine/redmine.git
synced 2025-11-14 01:06:00 +01:00
Merged Rails 2.2 branch. Redmine now requires Rails 2.2.2.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2493 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -2,11 +2,15 @@
|
||||
# within the database.
|
||||
class PluginMigrationGenerator < Rails::Generator::Base
|
||||
|
||||
# 255 characters max for Windows NTFS (http://en.wikipedia.org/wiki/Filename)
|
||||
# minus 14 for timestamp, minus some extra chars for dot, underscore, file
|
||||
# extension. So let's have 230.
|
||||
MAX_FILENAME_LENGTH = 230
|
||||
|
||||
def initialize(runtime_args, runtime_options={})
|
||||
super
|
||||
@options = {:assigns => {}}
|
||||
|
||||
ensure_plugin_schema_table_exists
|
||||
ensure_schema_table_exists
|
||||
get_plugins_to_migrate(runtime_args)
|
||||
|
||||
if @plugins_to_migrate.empty?
|
||||
@@ -25,10 +29,9 @@ class PluginMigrationGenerator < Rails::Generator::Base
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
# Create the plugin schema table if it doesn't already exist. See
|
||||
# Engines::RailsExtensions::Migrations#initialize_schema_migrations_table_with_engine_additions
|
||||
def ensure_plugin_schema_table_exists
|
||||
|
||||
# Create the schema table if it doesn't already exist.
|
||||
def ensure_schema_table_exists
|
||||
ActiveRecord::Base.connection.initialize_schema_migrations_table
|
||||
end
|
||||
|
||||
@@ -69,11 +72,27 @@ class PluginMigrationGenerator < Rails::Generator::Base
|
||||
@options[:assigns][:current_versions] = @current_versions
|
||||
end
|
||||
|
||||
# Construct a unique migration name based on the plugins involved and the
|
||||
# versions they should reach after this migration is run.
|
||||
# Returns a migration name. If the descriptive migration name based on the
|
||||
# plugin names involved is shorter than 230 characters that one will be
|
||||
# used. Otherwise a shorter name will be returned.
|
||||
def build_migration_name
|
||||
returning descriptive_migration_name do |name|
|
||||
name.replace short_migration_name if name.length > MAX_FILENAME_LENGTH
|
||||
end
|
||||
end
|
||||
|
||||
# Construct a unique migration name based on the plugins involved and the
|
||||
# versions they should reach after this migration is run. The name constructed
|
||||
# needs to be lowercase
|
||||
def descriptive_migration_name
|
||||
@plugins_to_migrate.map do |plugin|
|
||||
"#{plugin.name}_to_version_#{@new_versions[plugin.name]}"
|
||||
end.join("_and_")
|
||||
end
|
||||
end.join("_and_").downcase
|
||||
end
|
||||
|
||||
# Short migration name that will be used if the descriptive_migration_name
|
||||
# exceeds 230 characters
|
||||
def short_migration_name
|
||||
'plugin_migrations'
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user