mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 11:44:02 +00:00
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:
parent
a4d7a1a771
commit
f8266b29ee
1 changed files with 8 additions and 0 deletions
|
|
@ -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?
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue