lib/engine2/core.rb in engine2-1.0.0 vs lib/engine2/core.rb in engine2-1.0.1

- old
+ new

@@ -283,10 +283,11 @@ module DatasetMethods def ensure_primary_key pk = @model.primary_keys + raise Engine2::E2Error.new("No primary key defined for model #{model}") unless pk && pk.all? if opts_select = @opts[:select] sel_pk = [] opts_select.each do |sel| name = case sel @@ -454,18 +455,27 @@ def self.boot &blk @boot_blk = blk end + def self.model_boot &blk + @model_boot_blk = blk + end + def self.bootstrap app = APP_LOCATION require 'engine2/pre_bootstrap' t = Time.now Action.count = 0 SCHEMES.clear + Sequel::DATABASES.each do |db| + db.models.each{|n, m| Object.send(:remove_const, n) if Object.const_defined?(n)} unless db == E2DB || db == DUMMYDB + end + load "#{app}/boot.rb" Sequel::DATABASES.each &:load_schema_cache_from_file + @model_boot_blk.() if @model_boot_blk load 'engine2/models/Files.rb' load 'engine2/models/UserInfo.rb' Dir["#{app}/models/*"].each{|m| load m} puts "MODELS, Time: #{Time.now - t}" Sequel::DATABASES.each &:dump_schema_cache_to_file