-
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?
Conversation
@@ -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 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.
@@ -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 |
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.
@@ -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 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.
@@ -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 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.
@@ -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 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.
@wiggly Thanks for this. I get the idea, I'd been thinking about dropping in an orm_adapters folder and requiring those prior to loading seeds.rake. There are currently some active_record environment dependencies in seeds.rake, I'd like to pull them out and keep seeds.rake clean. If you were to structure this PR in that way, I could do the same for Rails do you think? |
Add a new rake task to set up db layers for non-rails setups and update README to provide at least one example of this.