Sha256: abae04a4ff00dc39da6e557810772d4d15421a7660203475f0786847ae986773

Contents?: true

Size: 1.27 KB

Versions: 1

Compression:

Stored size: 1.27 KB

Contents

ActiveRecord::ConnectionAdapters::SchemaStatements.module_eval do
  def initialize_schema_information_with_plugins
    initialize_schema_information_without_plugins

    unless Desert::PluginMigrations::Migrator.legacy_schema_table_exists?
      execute "CREATE TABLE #{Desert::PluginMigrations::Migrator.schema_info_table_name} (plugin_name #{type_to_sql(:string)}, version #{type_to_sql(:integer)})"
    end
  end
  alias_method_chain :initialize_schema_information, :plugins

  def dump_schema_information_with_plugins
    schema_information = []

    dump = dump_schema_information_without_plugins
    schema_information << dump if dump

    if Desert::PluginMigrations::Migrator.legacy_schema_table_exists?
      plugins = ActiveRecord::Base.connection.select_all("SELECT * FROM #{Desert::PluginMigrations::Migrator.schema_info_table_name}")
      plugins.each do |plugin|
        if (version = plugin['version'].to_i) > 0
          plugin_name = ActiveRecord::Base.quote_value(plugin['plugin_name'])
          schema_information << "INSERT INTO #{Desert::PluginMigrations::Migrator.schema_info_table_name} (plugin_name, version) VALUES (#{plugin_name}, #{version})"
        end
      end
    end

    schema_information.join(";\n")
  end
  alias_method_chain :dump_schema_information, :plugins
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
desert-0.5.4 lib/desert/plugin_migrations/1.2/extensions/schema_statements.rb