Permalink
Browse files

added a method to warn if community_engine migrations are not up to d…

…ate.
  • Loading branch information...
1 parent 4c70680 commit dc2c29c6a2a05d8106b0e71c45e29b2e5684a0ce Bruno Bornsztein committed May 14, 2008
Showing with 32 additions and 9 deletions.
  1. +3 −3 engine_config/boot.rb
  2. +27 −4 lib/community_engine.rb
  3. +2 −2 tasks/community_engine_tasks.rake
View
@@ -1,3 +1,6 @@
+CommunityEngine.check_for_pending_migrations
+
+
ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS.update(:database_manager => SqlSessionStore)
SqlSessionStore.session_class = MysqlSession
ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.update :line_grapher => '%Y%m%dT%H:%M:%S'
@@ -19,7 +22,6 @@
WhiteListHelper.attributes['embed'] = %w(src quality salign scale bgcolor align menu pluginspage type width height wmode flashvars)
WhiteListHelper.attributes['iframe'] = %w(src frameborder width height)
-
AppConfig.default_mce_options = {
:theme => 'advanced',
:browsers => %w{msie gecko safari},
@@ -45,8 +47,6 @@
:extended_valid_elements => "img[class|src|flashvars|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name|obj|param|embed|scale|wmode|salign|style],embed[src|quality|scale|salign|wmode|bgcolor|width|height|name|align|type|pluginspage|flashvars],object[align<bottom?left?middle?right?top|archive|border|class|classid|codebase|codetype|data|declare|dir<ltr?rtl|height|hspace|id|lang|name|style|tabindex|title|type|usemap|vspace|width]"
}
-
-
AppConfig.simple_mce_options = {
:theme => 'advanced',
:browsers => %w{msie gecko safari},
View
@@ -1,13 +1,36 @@
# CommunityEngine
module CommunityEngine
module ActiveRecordExtensions
-
def prepare_options_for_attachment_fu(options)
attachment_fu_options = options.symbolize_keys.merge({:storage => options['storage'].to_sym,
:max_size => options['max_size'].to_i.megabytes})
- end
-
+ end
end
+
+ class << self
+
+ def check_for_pending_migrations
+ newest_ce_migration = Engines.plugins[:community_engine].latest_migration
+ current_ce_version = guess_current_ce_version
+
+ pending = newest_ce_migration - current_ce_version
+ if pending > 0
+ puts "---"
+ puts "[COMMUNITY ENGINE] You have #{pending} pending CommunityEngine migrations:"
+ puts "CE is at #{newest_ce_migration}, but you have only migrated it to #{current_ce_version}"
+ puts "Please run 'script/generate plugin_migration' AND 'rake db:migrate' before continuing, or you will experience errors."
+ puts "---"
+ end
+ end
+
+ def guess_current_ce_version
+ # DUMB: checks your db/migrate and parses out the last CE migration to find out which version you're at
+ last_version = Dir["db/migrate/[0-9]*_community_engine_*.rb"].sort.last[/.*_community_engine_to_version_(\d+)/, 1]
+ last_version.to_i
+ end
+
+ end
+
end
-ActiveRecord::Base.send(:extend, CommunityEngine::ActiveRecordExtensions)
+ActiveRecord::Base.send(:extend, CommunityEngine::ActiveRecordExtensions)
@@ -20,10 +20,10 @@ namespace :community_engine do
end
desc 'Test the community_engine plugin.'
- Rake::TestTask.new(:test) do |t|
+ Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.pattern = 'vendor/plugins/community_engine/test/**/*_test.rb'
- t.verbose = true
+ t.verbose = true
end
Rake::Task['community_engine:test'].comment = "Run the community_engine plugin tests."

0 comments on commit dc2c29c

Please sign in to comment.