Module: Cardio::Schema
- Included in:
- Cardio
- Defined in:
- lib/cardio/schema.rb
Instance Method Summary collapse
- #assume_migrated_upto_version(type) ⇒ Object
- #schema(type = nil) ⇒ Object
- #schema_mode(type) {|paths| ... } ⇒ Object
- #schema_stamp_path(type) ⇒ Object
- #schema_suffix(type) ⇒ Object
Instance Method Details
#assume_migrated_upto_version(type) ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/cardio/schema.rb', line 3 def assume_migrated_upto_version type Cardio.schema_mode(type) do ActiveRecord::Schema.assume_migrated_upto_version( Cardio.schema(type), Cardio.migration_paths(type) ) end end |
#schema(type = nil) ⇒ Object
30 31 32 |
# File 'lib/cardio/schema.rb', line 30 def schema type=nil File.read(schema_stamp_path(type)).strip end |
#schema_mode(type) {|paths| ... } ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/cardio/schema.rb', line 19 def schema_mode type new_suffix = Cardio.schema_suffix type original_suffix = ActiveRecord::Base.table_name_suffix ActiveRecord::Base.table_name_suffix = new_suffix ActiveRecord::SchemaMigration.reset_table_name paths = Cardio.migration_paths(type) yield(paths) ActiveRecord::Base.table_name_suffix = original_suffix ActiveRecord::SchemaMigration.reset_table_name end |
#schema_stamp_path(type) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/cardio/schema.rb', line 34 def schema_stamp_path type root_dir = (type == :deck_cards ? root : gem_root) stamp_dir = ENV["SCHEMA_STAMP_PATH"] || File.join(root_dir, "db") File.join stamp_dir, "version#{schema_suffix type}.txt" end |
#schema_suffix(type) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/cardio/schema.rb', line 11 def schema_suffix type case type when :core_cards then "_core_cards" when :deck_cards then "_deck_cards" else "" end end |