Task to drop all ahoy events

The ChangeVisitIdTypeOfAhoyEventsToInteger from 364be5541 is not very well done.
You can not change the schema without changing possibly existing data.
Ahoy events used some kind of string as `visit_id`. Changing this column
to integrer will just barf up `Mysql2::Error: Truncated incorrect INTEGER value`.

So we need a way for people who are in this situation now to get out of it.
Luckily we completely dropped ahoy events a while ago so we can just delete them.
This commit is contained in:
Henne Vogelsang 2019-02-15 01:03:05 +01:00
parent a4d7a1a771
commit f8266b29ee

View file

@ -17,6 +17,14 @@ namespace :data do
nullify_attribute(events_room, 'room_id')
end
desc 'Drop all ahoy events'
task drop_all_ahoy_events: :environment do
class TmpAhoy < ActiveRecord::Base
self.table_name = 'ahoy_events'
end
TmpAhoy.delete_all
end
def nullify_attribute(collection, attribute)
puts "Will nullify #{attribute} in #{ActionController::Base.helpers.pluralize(collection.length, 'event')}."
if collection.any?