Include autenticazione, progetti isolati, mail marketing HTML con SMTP, test A/B e editor WYSIWYG. Co-authored-by: Cursor <cursoragent@cursor.com>
80 lines
2.7 KiB
Ruby
80 lines
2.7 KiB
Ruby
class CreateMailMarketing < ActiveRecord::Migration[8.1]
|
|
def change
|
|
create_table :mail_identities do |t|
|
|
t.string :name, null: false
|
|
t.string :from_name, null: false
|
|
t.string :from_email, null: false
|
|
t.string :reply_to
|
|
t.string :smtp_host, null: false
|
|
t.integer :smtp_port, null: false, default: 587
|
|
t.string :smtp_username
|
|
t.text :smtp_password
|
|
t.string :smtp_authentication, default: "plain", null: false
|
|
t.string :encryption, default: "starttls", null: false
|
|
t.boolean :verify_ssl, default: true, null: false
|
|
t.boolean :active, default: true, null: false
|
|
t.bigint :created_by_id
|
|
t.bigint :updated_by_id
|
|
t.timestamps
|
|
end
|
|
add_index :mail_identities, :from_email
|
|
add_index :mail_identities, :active
|
|
|
|
create_table :mail_templates do |t|
|
|
t.bigint :project_id
|
|
t.string :name, null: false
|
|
t.string :subject, null: false
|
|
t.text :body_html, null: false
|
|
t.bigint :created_by_id
|
|
t.bigint :updated_by_id
|
|
t.timestamps
|
|
end
|
|
add_index :mail_templates, :project_id
|
|
add_index :mail_templates, :name
|
|
|
|
create_table :mailings do |t|
|
|
t.bigint :project_id, null: false
|
|
t.bigint :mail_identity_id, null: false
|
|
t.bigint :mail_template_id
|
|
t.string :name, null: false
|
|
t.string :subject, null: false
|
|
t.text :body_html, null: false
|
|
t.string :audience, default: "to_send", null: false
|
|
t.string :status, default: "draft", null: false
|
|
t.integer :interval_seconds, default: 0, null: false
|
|
t.datetime :queued_at
|
|
t.datetime :completed_at
|
|
t.bigint :created_by_id
|
|
t.bigint :updated_by_id
|
|
t.timestamps
|
|
end
|
|
add_index :mailings, :project_id
|
|
add_index :mailings, :mail_identity_id
|
|
add_index :mailings, :status
|
|
|
|
create_table :mailing_recipients do |t|
|
|
t.bigint :mailing_id, null: false
|
|
t.bigint :organization_id, null: false
|
|
t.bigint :contact_id
|
|
t.string :email
|
|
t.string :status, default: "pending", null: false
|
|
t.string :skip_reason
|
|
t.text :error_message
|
|
t.string :rendered_subject
|
|
t.datetime :sent_at
|
|
t.timestamps
|
|
end
|
|
add_index :mailing_recipients, %i[mailing_id organization_id], unique: true, name: "idx_mailing_recipients_unique"
|
|
add_index :mailing_recipients, :status
|
|
add_index :mailing_recipients, :email
|
|
|
|
add_foreign_key :mail_templates, :projects
|
|
add_foreign_key :mailings, :projects
|
|
add_foreign_key :mailings, :mail_identities
|
|
add_foreign_key :mailings, :mail_templates
|
|
add_foreign_key :mailing_recipients, :mailings
|
|
add_foreign_key :mailing_recipients, :organizations
|
|
add_foreign_key :mailing_recipients, :contacts
|
|
end
|
|
end
|