Class: Chicago::RakeTasks
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- Chicago::RakeTasks
- Defined in:
- lib/chicago/rake_tasks.rb
Overview
Rake tasks for a Chicago project.
To use, simply include:
Chicago::RakeTasks.new(db, schema)
in your project’s Rakefile.
Provides the following tasks:
db:create_null_records
-
creates all the null dimension records in db
db:create_etl_tables
-
defines the tables used for ETL batches and the like
db:write_migrations
-
writes the auto migrations to a “migrations” directory.
Instance Method Summary collapse
-
#define ⇒ Object
private
Defines the rake tasks.
-
#initialize(schema, options) ⇒ RakeTasks
constructor
A new instance of RakeTasks.
Constructor Details
#initialize(schema, options) ⇒ RakeTasks
Returns a new instance of RakeTasks.
23 24 25 26 27 28 29 30 |
# File 'lib/chicago/rake_tasks.rb', line 23 def initialize(schema, ) @schema = schema @base_migration_dir = [:migration_directory] ||= "migrations" @staging_db = [:staging_db] or raise ArgumentError.new("staging_db option must be provided.") @presentation_db = [:presentation_db] define end |
Instance Method Details
#define ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Defines the rake tasks.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/chicago/rake_tasks.rb', line 35 def define namespace :db do desc "Write Null dimension records" task :create_null_records do # TODO: replace this with proper logging. warn "Loading NULL records." @schema.dimensions.each do |dimension| dimension.create_null_records(@staging_db) end end desc "Writes a migration file to change the database based on defined Facts & Dimensions" task :write_migrations do writer = Database::MigrationFileWriter.new writer.write_migration_file(@staging_db, @schema, staging_directory) if @presentation_db writer.write_migration_file(@presentation_db, @schema, presentation_directory, false) end end end end |