From f7117646afddb2676e9275d8efe90c3a20c59021 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Mon, 12 Apr 2021 12:37:14 +0200 Subject: Add cold-start follow recommendations (#15945) --- db/migrate/20210322164601_create_account_summaries.rb | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 db/migrate/20210322164601_create_account_summaries.rb (limited to 'db/migrate/20210322164601_create_account_summaries.rb') diff --git a/db/migrate/20210322164601_create_account_summaries.rb b/db/migrate/20210322164601_create_account_summaries.rb new file mode 100644 index 000000000..b9faf180d --- /dev/null +++ b/db/migrate/20210322164601_create_account_summaries.rb @@ -0,0 +1,9 @@ +class CreateAccountSummaries < ActiveRecord::Migration[5.2] + def change + create_view :account_summaries, materialized: true + + # To be able to refresh the view concurrently, + # at least one unique index is required + safety_assured { add_index :account_summaries, :account_id, unique: true } + end +end -- cgit From d8e0c8a89e1f1dd1c4ce1513deaeb3c85c6e4a42 Mon Sep 17 00:00:00 2001 From: Claire Date: Fri, 7 May 2021 18:14:29 +0200 Subject: Do not populate AccountSummaries and FollowRecommendation views on migration (#16173) Materializing those views can take a while, and they are currently refreshed anyway each time they are actually used, in the FollowRecommendationsScheduler. --- db/migrate/20210322164601_create_account_summaries.rb | 2 +- db/migrate/20210505174616_update_follow_recommendations_to_version_2.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'db/migrate/20210322164601_create_account_summaries.rb') diff --git a/db/migrate/20210322164601_create_account_summaries.rb b/db/migrate/20210322164601_create_account_summaries.rb index b9faf180d..bc9011113 100644 --- a/db/migrate/20210322164601_create_account_summaries.rb +++ b/db/migrate/20210322164601_create_account_summaries.rb @@ -1,6 +1,6 @@ class CreateAccountSummaries < ActiveRecord::Migration[5.2] def change - create_view :account_summaries, materialized: true + create_view :account_summaries, materialized: { no_data: true } # To be able to refresh the view concurrently, # at least one unique index is required diff --git a/db/migrate/20210505174616_update_follow_recommendations_to_version_2.rb b/db/migrate/20210505174616_update_follow_recommendations_to_version_2.rb index 9b2a284e4..56c0b4cb0 100644 --- a/db/migrate/20210505174616_update_follow_recommendations_to_version_2.rb +++ b/db/migrate/20210505174616_update_follow_recommendations_to_version_2.rb @@ -4,7 +4,7 @@ class UpdateFollowRecommendationsToVersion2 < ActiveRecord::Migration[6.1] def up drop_view :follow_recommendations - create_view :follow_recommendations, version: 2, materialized: true + create_view :follow_recommendations, version: 2, materialized: { no_data: true } # To be able to refresh the view concurrently, # at least one unique index is required -- cgit