completed SMS gateway project

This commit is contained in:
Min Zeya Phyo
2025-10-22 17:22:17 +08:00
commit c883fa7128
190 changed files with 16294 additions and 0 deletions

117
db/schema.rb generated Normal file
View File

@@ -0,0 +1,117 @@
# 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[8.0].define(version: 2025_10_20_031401) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_catalog.plpgsql"
create_table "admin_users", force: :cascade do |t|
t.string "email", null: false
t.string "password_digest", null: false
t.string "name", null: false
t.datetime "last_login_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["email"], name: "index_admin_users_on_email", unique: true
end
create_table "api_keys", force: :cascade do |t|
t.string "name", null: false
t.string "key_digest", null: false
t.string "key_prefix", null: false
t.boolean "active", default: true
t.datetime "last_used_at"
t.datetime "expires_at"
t.jsonb "permissions", default: {}
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["active"], name: "index_api_keys_on_active"
t.index ["key_digest"], name: "index_api_keys_on_key_digest", unique: true
t.index ["key_prefix"], name: "index_api_keys_on_key_prefix"
end
create_table "gateways", force: :cascade do |t|
t.string "device_id", null: false
t.string "name"
t.string "api_key_digest", null: false
t.string "status", default: "offline"
t.datetime "last_heartbeat_at"
t.integer "messages_sent_today", default: 0
t.integer "messages_received_today", default: 0
t.integer "total_messages_sent", default: 0
t.integer "total_messages_received", default: 0
t.boolean "active", default: true
t.integer "priority", default: 1
t.jsonb "metadata", default: {}
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["active"], name: "index_gateways_on_active"
t.index ["device_id"], name: "index_gateways_on_device_id", unique: true
t.index ["status"], name: "index_gateways_on_status"
end
create_table "otp_codes", force: :cascade do |t|
t.string "phone_number", null: false
t.string "code", null: false
t.string "purpose", default: "authentication"
t.datetime "expires_at", null: false
t.boolean "verified", default: false
t.datetime "verified_at"
t.integer "attempts", default: 0
t.string "ip_address"
t.jsonb "metadata", default: {}
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["expires_at"], name: "index_otp_codes_on_expires_at"
t.index ["phone_number", "verified", "expires_at"], name: "index_otp_codes_on_phone_number_and_verified_and_expires_at"
t.index ["phone_number"], name: "index_otp_codes_on_phone_number"
end
create_table "sms_messages", force: :cascade do |t|
t.bigint "gateway_id"
t.string "message_id", null: false
t.string "direction", null: false
t.string "phone_number", null: false
t.text "message_body", null: false
t.string "status", default: "pending"
t.text "error_message"
t.integer "retry_count", default: 0
t.datetime "sent_at"
t.datetime "delivered_at"
t.datetime "failed_at"
t.jsonb "metadata", default: {}
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["direction"], name: "index_sms_messages_on_direction"
t.index ["gateway_id"], name: "index_sms_messages_on_gateway_id"
t.index ["message_id"], name: "index_sms_messages_on_message_id", unique: true
t.index ["phone_number", "created_at"], name: "index_sms_messages_on_phone_number_and_created_at"
t.index ["phone_number"], name: "index_sms_messages_on_phone_number"
t.index ["status", "created_at"], name: "index_sms_messages_on_status_and_created_at"
end
create_table "webhook_configs", force: :cascade do |t|
t.string "name", null: false
t.string "url", null: false
t.string "event_type", null: false
t.string "secret_key"
t.boolean "active", default: true
t.integer "timeout", default: 30
t.integer "retry_count", default: 3
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["active"], name: "index_webhook_configs_on_active"
t.index ["event_type"], name: "index_webhook_configs_on_event_type"
end
add_foreign_key "sms_messages", "gateways"
end