From af5b4140ddd027a43f38c256d603aba640d7da53 Mon Sep 17 00:00:00 2001 From: Ari Timonen Date: Thu, 2 Apr 2020 03:08:34 +0300 Subject: [PATCH] Migrate readings to read_marks --- db/migrate/20200402000314_move_readings_to_read_marks.rb | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 db/migrate/20200402000314_move_readings_to_read_marks.rb diff --git a/db/migrate/20200402000314_move_readings_to_read_marks.rb b/db/migrate/20200402000314_move_readings_to_read_marks.rb new file mode 100644 index 0000000..161a1b1 --- /dev/null +++ b/db/migrate/20200402000314_move_readings_to_read_marks.rb @@ -0,0 +1,8 @@ +class MoveReadingsToReadMarks < ActiveRecord::Migration[6.0] + def change + # execute "TRUNCATE read_marks" + execute "INSERT INTO read_marks (readable_type, readable_id, reader_type, reader_id, timestamp) + SELECT readable_type, readable_id, "User", user_id, updated_at + FROM readings;" + end +end