ensl.org/db/migrate/20200402000314_move_readings_to_read_marks.rb

9 lines
368 B
Ruby
Raw Normal View History

2020-04-02 00:08:34 +00:00
class MoveReadingsToReadMarks < ActiveRecord::Migration[6.0]
def change
2020-04-02 00:24:23 +00:00
execute "TRUNCATE read_marks"
2020-04-02 00:08:34 +00:00
execute "INSERT INTO read_marks (readable_type, readable_id, reader_type, reader_id, timestamp)
2020-04-02 00:16:03 +00:00
SELECT readable_type, readable_id, 'User', user_id, updated_at
2020-04-02 00:24:23 +00:00
FROM readings GROUP BY readable_type, readable_id, user_id;"
2020-04-02 00:08:34 +00:00
end
end