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

56
services/db/schema.rb generated Normal file
View File

@ -0,0 +1,56 @@
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# This file is the source Rails uses to define your schema when running `bin/rails
# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
# be faster and is potentially less error prone than running all of your
# migrations from scratch. Old migrations may fail to apply correctly if those
# migrations use external dependencies or application code.
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2022_11_15_164901) do
# These are extensions that must be enabled in order to support this database
enable_extension "pgcrypto"
enable_extension "plpgsql"
enable_extension "uuid-ossp"
create_table "mail_recipients", id: false, force: :cascade do |t|
t.uuid "received_mail_id"
t.string "recipient_id"
t.string "delivery_status", default: "delivered"
t.string "delivery_status_changed_at"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.index ["received_mail_id", "recipient_id"], name: "index_mail_recipients_on_received_mail_id_and_recipient_id", unique: true
end
create_table "received_mails", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.string "sender_id"
t.string "message_id"
t.binary "body"
t.string "delivery_status", default: "queued"
t.string "delivery_status_changed_at"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.index ["message_id"], name: "index_received_mails_on_message_id", unique: true
t.index ["sender_id"], name: "index_received_mails_on_sender_id"
end
create_table "recipients", id: :string, force: :cascade do |t|
t.string "verification_status", default: "unverified"
t.datetime "last_verified_at"
t.string "bounce_status", default: "unknown"
t.datetime "bounce_status_changed_at"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
end
create_table "senders", id: :string, force: :cascade do |t|
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
end
end

7
services/db/seeds.rb Normal file
View File

@ -0,0 +1,7 @@
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Character.create(name: 'Luke', movie: movies.first)