# 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[7.1].define(version: 2024_10_13_040658) do create_schema "e621" # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" create_table "active_storage_attachments", force: :cascade do |t| t.string "name", null: false t.string "record_type", null: false t.bigint "record_id", null: false t.bigint "blob_id", null: false t.datetime "created_at", null: false t.index ["blob_id"], name: "index_active_storage_attachments_on_blob_id" t.index ["record_type", "record_id", "name", "blob_id"], name: "index_active_storage_attachments_uniqueness", unique: true end create_table "active_storage_blobs", force: :cascade do |t| t.string "key", null: false t.string "filename", null: false t.string "content_type" t.text "metadata" t.string "service_name", null: false t.bigint "byte_size", null: false t.string "checksum" t.datetime "created_at", null: false t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true end create_table "active_storage_variant_records", force: :cascade do |t| t.bigint "blob_id", null: false t.string "variation_digest", null: false t.index ["blob_id", "variation_digest"], name: "index_active_storage_variant_records_uniqueness", unique: true end create_table "api_images", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.bigint "creator_id", null: false t.inet "creator_ip_addr", null: false t.string "artists", default: [], array: true t.string "sources", default: [], array: true t.integer "width", null: false t.integer "height", null: false t.string "mime_type", null: false t.string "category", null: false t.string "original_url" t.string "file_ext", null: false t.integer "file_size", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false t.bigserial "iqdb_id", null: false t.index ["creator_id"], name: "index_api_images_on_creator_id" end create_table "api_keys", force: :cascade do |t| t.bigint "owner_id", null: false t.boolean "active", default: true, null: false t.boolean "disabled", default: false, null: false t.boolean "super", default: false, null: false t.boolean "unlimited", default: false, null: false t.integer "bulk_limit", default: 100, null: false t.integer "flags", default: 7, null: false t.integer "limit_long", default: 12, null: false t.integer "limit_short", default: 4, null: false t.integer "window_long", default: 10000, null: false t.integer "window_short", default: 2000, null: false t.string "application_name", null: false t.string "usage", default: "", null: false t.string "disabled_reason" t.string "key", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false t.index ["owner_id"], name: "index_api_keys_on_owner_id" end create_table "api_usages", force: :cascade do |t| t.bigint "user_id" t.bigint "api_key_id" t.text "user_agent", default: "", null: false t.text "method", default: "GET", null: false t.text "path", default: "/", null: false t.jsonb "params", default: "{}", null: false t.text "service", null: false t.inet "ip_addr", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false t.index ["api_key_id"], name: "index_api_usages_on_api_key_id" t.index ["user_id"], name: "index_api_usages_on_user_id" end create_table "api_users", force: :cascade do |t| t.integer "level", null: false t.string "name", null: false t.string "last_avatar_hash" t.datetime "created_at", null: false t.datetime "updated_at", null: false end create_table "e621_statuses", force: :cascade do |t| t.integer "status", null: false t.datetime "created_at", precision: 3, null: false end create_table "e621_thumbnails", force: :cascade do |t| t.bigint "creator_id", null: false t.bigint "api_key_id" t.inet "creator_ip_addr", null: false t.integer "post_id", null: false t.uuid "md5", null: false t.string "status", default: "pending", null: false t.string "filetype", null: false t.string "error_code" t.datetime "expires_at" t.datetime "created_at", null: false t.datetime "updated_at", null: false t.index ["api_key_id"], name: "index_e621_thumbnails_on_api_key_id" t.index ["creator_id"], name: "index_e621_thumbnails_on_creator_id" end create_table "e621_webhooks", force: :cascade do |t| t.string "channel_id", null: false t.string "creator_id" t.string "guild_id", null: false t.string "webhook_id", null: false t.string "webhook_token", null: false t.datetime "created_at", null: false end create_table "exception_logs", force: :cascade do |t| t.string "class_name" t.inet "ip_addr" t.string "version" t.text "extra_params" t.text "message" t.text "trace" t.uuid "code" t.datetime "created_at", null: false t.datetime "updated_at", null: false end create_table "good_job_batches", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.datetime "created_at", null: false t.datetime "updated_at", null: false t.text "description" t.jsonb "serialized_properties" t.text "on_finish" t.text "on_success" t.text "on_discard" t.text "callback_queue_name" t.integer "callback_priority" t.datetime "enqueued_at" t.datetime "discarded_at" t.datetime "finished_at" end create_table "good_job_executions", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.datetime "created_at", null: false t.datetime "updated_at", null: false t.uuid "active_job_id", null: false t.text "job_class" t.text "queue_name" t.jsonb "serialized_params" t.datetime "scheduled_at" t.datetime "finished_at" t.text "error" t.integer "error_event", limit: 2 t.text "error_backtrace", array: true t.uuid "process_id" t.interval "duration" t.index ["active_job_id", "created_at"], name: "index_good_job_executions_on_active_job_id_and_created_at" t.index ["process_id", "created_at"], name: "index_good_job_executions_on_process_id_and_created_at" end create_table "good_job_processes", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.datetime "created_at", null: false t.datetime "updated_at", null: false t.jsonb "state" t.integer "lock_type", limit: 2 end create_table "good_job_settings", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.datetime "created_at", null: false t.datetime "updated_at", null: false t.text "key" t.jsonb "value" t.index ["key"], name: "index_good_job_settings_on_key", unique: true end create_table "good_jobs", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.text "queue_name" t.integer "priority" t.jsonb "serialized_params" t.datetime "scheduled_at" t.datetime "performed_at" t.datetime "finished_at" t.text "error" t.datetime "created_at", null: false t.datetime "updated_at", null: false t.uuid "active_job_id" t.text "concurrency_key" t.text "cron_key" t.uuid "retried_good_job_id" t.datetime "cron_at" t.uuid "batch_id" t.uuid "batch_callback_id" t.boolean "is_discrete" t.integer "executions_count" t.text "job_class" t.integer "error_event", limit: 2 t.text "labels", array: true t.uuid "locked_by_id" t.datetime "locked_at" t.index ["active_job_id", "created_at"], name: "index_good_jobs_on_active_job_id_and_created_at" t.index ["batch_callback_id"], name: "index_good_jobs_on_batch_callback_id", where: "(batch_callback_id IS NOT NULL)" t.index ["batch_id"], name: "index_good_jobs_on_batch_id", where: "(batch_id IS NOT NULL)" t.index ["concurrency_key"], name: "index_good_jobs_on_concurrency_key_when_unfinished", where: "(finished_at IS NULL)" t.index ["cron_key", "created_at"], name: "index_good_jobs_on_cron_key_and_created_at_cond", where: "(cron_key IS NOT NULL)" t.index ["cron_key", "cron_at"], name: "index_good_jobs_on_cron_key_and_cron_at_cond", unique: true, where: "(cron_key IS NOT NULL)" t.index ["finished_at"], name: "index_good_jobs_jobs_on_finished_at", where: "((retried_good_job_id IS NULL) AND (finished_at IS NOT NULL))" t.index ["labels"], name: "index_good_jobs_on_labels", where: "(labels IS NOT NULL)", using: :gin t.index ["locked_by_id"], name: "index_good_jobs_on_locked_by_id", where: "(locked_by_id IS NOT NULL)" t.index ["priority", "created_at"], name: "index_good_job_jobs_for_candidate_lookup", where: "(finished_at IS NULL)" t.index ["priority", "created_at"], name: "index_good_jobs_jobs_on_priority_created_at_when_unfinished", order: { priority: "DESC NULLS LAST" }, where: "(finished_at IS NULL)" t.index ["priority", "scheduled_at"], name: "index_good_jobs_on_priority_scheduled_at_unfinished_unlocked", where: "((finished_at IS NULL) AND (locked_by_id IS NULL))" t.index ["queue_name", "scheduled_at"], name: "index_good_jobs_on_queue_name_and_scheduled_at", where: "(finished_at IS NULL)" t.index ["scheduled_at"], name: "index_good_jobs_on_scheduled_at", where: "(finished_at IS NULL)" end create_table "short_urls", force: :cascade do |t| t.bigint "creator_id", null: false t.bigint "api_key_id" t.inet "creator_ip_addr", null: false t.string "code", null: false t.string "url", null: false t.integer "hits", default: 0, null: false t.string "creator_name", null: false t.string "creator_ua", null: false t.string "management_code" t.datetime "created_at", null: false t.datetime "updated_at", null: false t.index ["api_key_id"], name: "index_short_urls_on_api_key_id" t.index ["code"], name: "index_short_urls_on_code", unique: true t.index ["creator_id"], name: "index_short_urls_on_creator_id" end add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id" add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id" add_foreign_key "api_images", "api_users", column: "creator_id" add_foreign_key "api_keys", "api_users", column: "owner_id" add_foreign_key "api_usages", "api_users", column: "user_id" add_foreign_key "e621_thumbnails", "api_users", column: "creator_id" add_foreign_key "short_urls", "api_users", column: "creator_id" end