Ogni destinatario mostra se la mail è partita e se è stata aperta, con conteggi in dashboard. Co-authored-by: Cursor <cursoragent@cursor.com>
25 lines
724 B
Ruby
25 lines
724 B
Ruby
class AddOpenTrackingToMailingRecipients < ActiveRecord::Migration[8.1]
|
|
def change
|
|
change_table :mailing_recipients do |t|
|
|
t.string :tracking_token
|
|
t.datetime :opened_at
|
|
t.datetime :last_opened_at
|
|
t.integer :open_count, null: false, default: 0
|
|
end
|
|
|
|
reversible do |dir|
|
|
dir.up do
|
|
execute <<~SQL.squish
|
|
UPDATE mailing_recipients
|
|
SET tracking_token = replace(gen_random_uuid()::text, '-', '')
|
|
WHERE tracking_token IS NULL
|
|
SQL
|
|
change_column_null :mailing_recipients, :tracking_token, false
|
|
end
|
|
end
|
|
|
|
add_index :mailing_recipients, :tracking_token, unique: true
|
|
add_index :mailing_recipients, :opened_at
|
|
end
|
|
end
|