diff --git a/db/migrate/20240910145644_add_pieces_jointes_seen_at_to_follows.rb b/db/migrate/20240910145644_add_pieces_jointes_seen_at_to_follows.rb new file mode 100644 index 000000000..cce53f945 --- /dev/null +++ b/db/migrate/20240910145644_add_pieces_jointes_seen_at_to_follows.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +class AddPiecesJointesSeenAtToFollows < ActiveRecord::Migration[7.0] + def up + add_column :follows, :pieces_jointes_seen_at, :datetime + change_column_default :follows, :pieces_jointes_seen_at, from: nil, to: 'CURRENT_TIMESTAMP' + end + + def down + remove_column :follows, :pieces_jointes_seen_at + end +end diff --git a/db/migrate/20240911064340_backfill_follows_with_pieces_jointes_seen_at.rb b/db/migrate/20240911064340_backfill_follows_with_pieces_jointes_seen_at.rb new file mode 100644 index 000000000..82a51de34 --- /dev/null +++ b/db/migrate/20240911064340_backfill_follows_with_pieces_jointes_seen_at.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +class BackfillFollowsWithPiecesJointesSeenAt < ActiveRecord::Migration[7.0] + disable_ddl_transaction! + def up + Follow.in_batches do |relation| + relation.update_all pieces_jointes_seen_at: Time.zone.now + sleep(0.001) # throttle + end + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index fd9774819..e55fcb86b 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -691,6 +691,7 @@ ActiveRecord::Schema[7.0].define(version: 2024_09_23_125619) do t.integer "dossier_id", null: false t.integer "instructeur_id", null: false t.datetime "messagerie_seen_at", precision: nil, null: false + t.datetime "pieces_jointes_seen_at" t.datetime "unfollowed_at", precision: nil t.datetime "updated_at", precision: nil t.index ["dossier_id"], name: "index_follows_on_dossier_id"