Skip to content
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

Fix create_tables rake task #317

Merged
merged 3 commits into from
Nov 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,7 @@ module DynamoidReset
end
Dynamoid.adapter.tables.clear
# Recreate all tables to avoid unexpected errors
Dynamoid.included_models.each(&:create_table)
Dynamoid.included_models.each { |m| m.create_table(sync: true) }
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/dynamoid/tasks/database.rake
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace :dynamoid do
desc 'Creates DynamoDB tables, one for each of your Dynamoid models - does not modify pre-existing tables'
task create_tables: :environment do
# Load models so Dynamoid will be able to discover tables expected.
Dir[File.join(Dynamoid::Config.models_dir, '*.rb')].sort.each { |file| require file }
Dir[File.join(Dynamoid::Config.models_dir, '**/*.rb')].sort.each { |file| require file }
if Dynamoid.included_models.any?
tables = Dynamoid::Tasks::Database.create_tables
result = tables[:created].map { |c| "#{c} created" } + tables[:existing].map { |e| "#{e} already exists" }
Expand Down
2 changes: 1 addition & 1 deletion lib/dynamoid/tasks/database.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def create_tables
if Dynamoid.adapter.list_tables.include? model.table_name
results[:existing] << model.table_name
else
model.create_table
model.create_table(sync: true)
results[:created] << model.table_name
end
end
Expand Down