added services

This commit is contained in:
Mike Sutton
2022-11-16 01:02:18 +01:00
parent 329e66c949
commit 9d256dfcba
52 changed files with 1419 additions and 0 deletions

View File

@ -0,0 +1,39 @@
class Setup < ActiveRecord::Migration[6.1]
def change
enable_extension 'uuid-ossp'
enable_extension 'pgcrypto'
create_table :senders, id: :string do |t|
t.timestamps
end
create_table :recipients, id: :string do |t|
t.string :verification_status, default: 'unverified', nullable: false
t.datetime :last_verified_at, nullable: true
t.string :bounce_status , default: 'unknown'
t.datetime :bounce_status_changed_at, nullable: true
t.timestamps
end
create_table :received_mails, id: :uuid do |t|
t.string :sender_id, nullable: false
t.string :message_id, nullable: false
t.binary :body, nullable: false
t.string :delivery_status, default: 'queued', nullable: false
t.string :delivery_status_changed_at
t.timestamps
end
create_table :mail_recipients, id: false do |t|
t.uuid :received_mail_id
t.string :recipient_id
t.string :delivery_status, default: 'delivered', nullable: false
t.string :delivery_status_changed_at
t.timestamps
end
add_index :received_mails, :sender_id
add_index :received_mails, :message_id, unique: true
add_index :mail_recipients, %i[received_mail_id recipient_id], unique: true
end
end