diff --git a/CHANGELOG.md b/CHANGELOG.md index be5c362c2..a51cb9868 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ - Ability to bulk-import members from a CSV file - Ability to disable invoices generation and interfaces - Added a known issue to the README (#152) +- Ability to fully rebuild the projets index in ElasticSearch with rake fablab:es:build_projects_index - Fix a bug: invoices with total = 0, are marked as paid on site even if paid by card - Fix a bug: after disabling a group, its associated plans are hidden from the interface - Fix a bug: in case of unexpected server error during stripe payment process, the confirm button is not unlocked diff --git a/db/migrate/20150107103903_add_slug_to_trainings.rb b/db/migrate/20150107103903_add_slug_to_trainings.rb index 69e0bec22..974b72af7 100644 --- a/db/migrate/20150107103903_add_slug_to_trainings.rb +++ b/db/migrate/20150107103903_add_slug_to_trainings.rb @@ -11,6 +11,6 @@ class AddSlugToTrainings < ActiveRecord::Migration def down remove_column :trainings, :slug, :string - remove_index :trainings, :slug, unique: true + remove_index :trainings, :slug end end diff --git a/lib/tasks/fablab/es.rake b/lib/tasks/fablab/es.rake index 16f3d4095..db66a5f1a 100644 --- a/lib/tasks/fablab/es.rake +++ b/lib/tasks/fablab/es.rake @@ -104,6 +104,19 @@ namespace :fablab do desc 'sync all/one project in ElasticSearch index' task :build_projects_index, [:id] => :environment do |_task, args| client = Project.__elasticsearch__.client + + # ask if we delete the index + print 'Delete all projects in ElasticSearch index? (y/n) ' + confirm = STDIN.gets.chomp + if confirm == 'y' + client.delete_by_query( + index: Project.index_name, + type: Project.document_type, + conflicts: 'proceed', + body: { query: { match_all: {} } } + ) + end + # create index if not exists Project.__elasticsearch__.create_index! force: true unless client.indices.exists? index: Project.index_name