-
Notifications
You must be signed in to change notification settings - Fork 91
Add rake task to setup DB layer for non-rails deployments #62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,10 @@ namespace :db do | |
override_dependency = ['db:seed:common'] | ||
|
||
namespace :seed do | ||
task :setup do | ||
# override in your Rakefile for your own DB backend setup | ||
end | ||
|
||
# Create seed tasks for all the seeds in seeds_path and add them to the dependency | ||
# list along with the original db/seeds.rb. | ||
common_dependencies = seed_tasks_matching(Seedbank.matcher) | ||
|
@@ -15,7 +19,7 @@ namespace :db do | |
end | ||
|
||
desc "Load the seed data from db/seeds.rb and db/seeds/#{Seedbank.matcher}." | ||
task 'common' => common_dependencies | ||
task 'common' => ['db:seed:setup'] + common_dependencies | ||
|
||
# Glob through the directories under seeds_path and create a task for each adding it to the dependency list. | ||
# Then create a task for the environment | ||
|
@@ -25,7 +29,7 @@ namespace :db do | |
environment_dependencies = seed_tasks_matching(environment, Seedbank.matcher) | ||
|
||
desc "Load the seed data from db/seeds.rb, db/seeds/#{Seedbank.matcher} and db/seeds/#{environment}/#{Seedbank.matcher}." | ||
task environment => ['db:seed:common'] + environment_dependencies | ||
task environment => ['db:seed:setup', 'db:seed:common'] + environment_dependencies | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
|
||
override_dependency << "db:seed:#{environment}" if defined?(Rails) && Rails.env == environment | ||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,7 @@ def self.glob_dummy_seeds | |
it 'creates all the seed tasks' do | ||
seeds = %w(db:seed:circular1 db:seed:circular2 db:seed:common db:seed:dependency db:seed:dependency2 | ||
db:seed:dependent db:seed:dependent_on_nested db:seed:dependent_on_several db:seed:development | ||
db:seed:development:users db:seed:no_block db:seed:original db:seed:reference_memos db:seed:with_block_memo db:seed:with_inline_memo) | ||
db:seed:development:users db:seed:no_block db:seed:original db:seed:reference_memos db:seed:setup db:seed:with_block_memo db:seed:with_inline_memo) | ||
|
||
subject.map(&:to_s).must_equal seeds | ||
end | ||
|
@@ -48,7 +48,7 @@ def self.glob_dummy_seeds | |
it 'is dependent on the common seeds and db:seed:original' do | ||
prerequisite_seeds = self.class.glob_dummy_seeds.sort.map do |seed_file| | ||
['db', 'seed', File.basename(seed_file, '.seeds.rb')].join(':') | ||
end.unshift('db:seed:original') | ||
end.unshift('db:seed:original').unshift('db:seed:setup') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
|
||
subject.prerequisites.must_equal prerequisite_seeds | ||
end | ||
|
@@ -68,7 +68,7 @@ def setup | |
it 'is dependent on only the common seeds' do | ||
prerequisite_seeds = self.class.glob_dummy_seeds.sort.map do |seed_file| | ||
['db', 'seed', File.basename(seed_file, '.seeds.rb')].join(':') | ||
end | ||
end.unshift('db:seed:setup') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
|
||
subject.prerequisites.must_equal prerequisite_seeds | ||
end | ||
|
@@ -134,7 +134,7 @@ def setup | |
it 'is dependent on the seeds in the environment directory' do | ||
prerequisite_seeds = Pathname.glob(environment_directory.join(Seedbank.matcher), Seedbank.nesting).sort.map do |seed_file| | ||
['db', 'seed', environment, File.basename(seed_file, '.seeds.rb')].join(':') | ||
end.unshift('db:seed:common') | ||
end.unshift('db:seed:common').unshift('db:seed:setup') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
|
||
subject.prerequisites.must_equal prerequisite_seeds | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.