Class: Genesis::Seeder
- Inherits:
-
Object
- Object
- Genesis::Seeder
- Defined in:
- lib/genesis/seeder.rb
Class Method Summary collapse
-
.empty_revisions_table ⇒ Object
Deletes all records from the schema_seeds table.
-
.get_current_version ⇒ Object
Returns the current seed version from the schema_seeds table.
- .load_schema_seed_model ⇒ Object
-
.run(seeds = [], to_version = nil, ignores = []) ⇒ Object
Runs the migration process.
-
.seed_version_table_exists? ⇒ Boolean
Checks if the schema_seeds table exists.
-
.verify_or_create_version_table ⇒ Object
Verifies that the schema_seeds table exists creating if if it does not exist.
Class Method Details
.empty_revisions_table ⇒ Object
Deletes all records from the schema_seeds table.
20 21 22 23 24 25 |
# File 'lib/genesis/seeder.rb', line 20 def self.empty_revisions_table if seed_version_table_exists? load_schema_seed_model SchemaSeed.delete_all end end |
.get_current_version ⇒ Object
Returns the current seed version from the schema_seeds table.
29 30 31 32 33 34 |
# File 'lib/genesis/seeder.rb', line 29 def self.get_current_version return 'No seed version table exists. Assuming seed version is 0.' unless seed_version_table_exists? load_schema_seed_model determine_current_version return @current_version end |
.load_schema_seed_model ⇒ Object
3 4 5 |
# File 'lib/genesis/seeder.rb', line 3 def self.load_schema_seed_model load( File.join(File.(File.dirname(__FILE__)), 'schema_seed.rb') ) end |
.run(seeds = [], to_version = nil, ignores = []) ⇒ Object
Runs the migration process.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/genesis/seeder.rb', line 44 def self.run( seeds=[], to_version=nil, ignores=[] ) ignores << 'genesis_callbacks.rb' @separator_size = 95 determine_current_version map_versions( seeds, ignores ) raise 'There are no seeds to execute.' if @versions_map.empty? to_version = determine_to_version( to_version ) determine_and_prepare_seed_direction( to_version ) if @to_run.empty? puts "The requested seed version (#{to_version}) resulted in no necessary seeding. Data is up to date." return end run_seeds end |
.seed_version_table_exists? ⇒ Boolean
Checks if the schema_seeds table exists.
38 39 40 |
# File 'lib/genesis/seeder.rb', line 38 def self.seed_version_table_exists? ActiveRecord::Base.connection.tables.include?( 'schema_seeds' ) end |
.verify_or_create_version_table ⇒ Object
Verifies that the schema_seeds table exists creating if if it does not exist.
9 10 11 12 13 14 15 16 |
# File 'lib/genesis/seeder.rb', line 9 def self.verify_or_create_version_table unless seed_version_table_exists? load( File.join(File.(File.dirname(__FILE__)), 'create_schema_seeds.rb') ) Genesis::CreateSchemaSeeds.up end load_schema_seed_model end |