diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2018-08-14 19:19:32 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-14 19:19:32 +0200 |
commit | 8e111b753a3411b258cdb008c9a53bad696f4df1 (patch) | |
tree | 6ae9387736b8abf180c93f7f0d25c6952c04b9b2 /db/migrate/20180812173710_copy_status_stats.rb | |
parent | 018a9e4e7fdfac0f2e482f4b5fa66247afbc2ddb (diff) |
Move status counters to separate table, count replies (#8104)
* Move status counters to separate table, count replies * Migration to remove old counter columns from statuses table * Fix schema file
Diffstat (limited to 'db/migrate/20180812173710_copy_status_stats.rb')
-rw-r--r-- | db/migrate/20180812173710_copy_status_stats.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/db/migrate/20180812173710_copy_status_stats.rb b/db/migrate/20180812173710_copy_status_stats.rb new file mode 100644 index 000000000..6ecccc0ae --- /dev/null +++ b/db/migrate/20180812173710_copy_status_stats.rb @@ -0,0 +1,19 @@ +class CopyStatusStats < ActiveRecord::Migration[5.2] + disable_ddl_transaction! + + def up + safety_assured do + execute <<-SQL.squish + INSERT INTO status_stats (status_id, reblogs_count, favourites_count) + SELECT id, reblogs_count, favourites_count + FROM statuses + ON CONFLICT (status_id) DO UPDATE + SET reblogs_count = EXCLUDED.reblogs_count, favourites_count = EXCLUDED.favourites_count + SQL + end + end + + def down + # Nothing + end +end |