| 1 | # This file is auto-generated from the current state of the database. Instead |
| 2 | # of editing this file, please use the migrations feature of Active Record to |
| 3 | # incrementally modify your database, and then regenerate this schema definition. |
| 4 | # |
| 5 | # This file is the source Rails uses to define your schema when running `bin/rails |
| 6 | # db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to |
| 7 | # be faster and is potentially less error prone than running all of your |
| 8 | # migrations from scratch. Old migrations may fail to apply correctly if those |
| 9 | # migrations use external dependencies or application code. |
| 10 | # |
| 11 | # It's strongly recommended that you check this file into your version control system. |
| 12 | |
| 13 | ActiveRecord::Schema[8.1].define(version: 2026_07_02_000002) do |
| 14 | # These are extensions that must be enabled in order to support this database |
| 15 | enable_extension "pg_catalog.plpgsql" |
| 16 | |
| 17 | create_table "cloud_messages", force: :cascade do |t| |
| 18 | t.uuid "cloud_session_id", null: false |
| 19 | t.text "content", default: "", null: false |
| 20 | t.datetime "created_at", null: false |
| 21 | t.string "role", null: false |
| 22 | t.datetime "updated_at", null: false |
| 23 | t.index ["cloud_session_id", "created_at"], name: "index_cloud_messages_on_cloud_session_id_and_created_at" |
| 24 | t.index ["cloud_session_id"], name: "index_cloud_messages_on_cloud_session_id" |
| 25 | end |
| 26 | |
| 27 | create_table "cloud_sessions", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| |
| 28 | t.datetime "created_at", null: false |
| 29 | t.datetime "last_message_at" |
| 30 | t.string "model", default: "onde-balanced", null: false |
| 31 | t.string "title", default: "New session", null: false |
| 32 | t.datetime "updated_at", null: false |
| 33 | t.bigint "user_id", null: false |
| 34 | t.index ["user_id", "updated_at"], name: "index_cloud_sessions_on_user_id_and_updated_at" |
| 35 | t.index ["user_id"], name: "index_cloud_sessions_on_user_id" |
| 36 | end |
| 37 | |
| 38 | create_table "cloud_usages", force: :cascade do |t| |
| 39 | t.datetime "created_at", null: false |
| 40 | t.string "period_key", null: false |
| 41 | t.integer "request_count", default: 0, null: false |
| 42 | t.datetime "updated_at", null: false |
| 43 | t.bigint "user_id", null: false |
| 44 | t.index ["user_id", "period_key"], name: "index_cloud_usages_on_user_id_and_period_key", unique: true |
| 45 | t.index ["user_id"], name: "index_cloud_usages_on_user_id" |
| 46 | end |
| 47 | |
| 48 | create_table "comments", force: :cascade do |t| |
| 49 | t.text "body", null: false |
| 50 | t.bigint "commentable_id", null: false |
| 51 | t.string "commentable_type", null: false |
| 52 | t.datetime "created_at", null: false |
| 53 | t.datetime "updated_at", null: false |
| 54 | t.bigint "user_id", null: false |
| 55 | t.index ["commentable_type", "commentable_id"], name: "index_comments_on_commentable" |
| 56 | t.index ["user_id"], name: "index_comments_on_user_id" |
| 57 | end |
| 58 | |
| 59 | create_table "github_app_installations", force: :cascade do |t| |
| 60 | t.string "access_token" |
| 61 | t.datetime "access_token_expires_at" |
| 62 | t.bigint "account_id" |
| 63 | t.string "account_login", null: false |
| 64 | t.string "account_type" |
| 65 | t.datetime "created_at", null: false |
| 66 | t.datetime "deleted_at" |
| 67 | t.bigint "installation_id", null: false |
| 68 | t.string "repository_selection" |
| 69 | t.datetime "suspended_at" |
| 70 | t.datetime "updated_at", null: false |
| 71 | t.index ["account_login"], name: "index_github_app_installations_on_account_login" |
| 72 | t.index ["installation_id"], name: "index_github_app_installations_on_installation_id", unique: true |
| 73 | end |
| 74 | |
| 75 | create_table "github_connections", force: :cascade do |t| |
| 76 | t.text "access_token", null: false |
| 77 | t.datetime "connected_at" |
| 78 | t.datetime "created_at", null: false |
| 79 | t.string "github_login" |
| 80 | t.string "scope" |
| 81 | t.string "token_type", default: "bearer", null: false |
| 82 | t.datetime "updated_at", null: false |
| 83 | t.bigint "user_id", null: false |
| 84 | t.index ["user_id"], name: "index_github_connections_on_user_id", unique: true |
| 85 | end |
| 86 | |
| 87 | create_table "github_pr_reviews", force: :cascade do |t| |
| 88 | t.integer "comment_count" |
| 89 | t.datetime "completed_at" |
| 90 | t.datetime "created_at", null: false |
| 91 | t.text "error_message" |
| 92 | t.bigint "github_app_installation_id", null: false |
| 93 | t.string "head_sha", null: false |
| 94 | t.string "model" |
| 95 | t.integer "pr_number", null: false |
| 96 | t.string "repo_full_name", null: false |
| 97 | t.string "skip_reason" |
| 98 | t.datetime "started_at" |
| 99 | t.string "status", default: "pending", null: false |
| 100 | t.datetime "updated_at", null: false |
| 101 | t.index ["github_app_installation_id"], name: "index_github_pr_reviews_on_github_app_installation_id" |
| 102 | t.index ["repo_full_name", "pr_number", "head_sha"], name: "index_github_pr_reviews_on_repo_pr_sha", unique: true |
| 103 | end |
| 104 | |
| 105 | create_table "issues", force: :cascade do |t| |
| 106 | t.text "body" |
| 107 | t.datetime "closed_at" |
| 108 | t.datetime "created_at", null: false |
| 109 | t.integer "number", null: false |
| 110 | t.bigint "repository_id", null: false |
| 111 | t.string "state", default: "open", null: false |
| 112 | t.string "title", null: false |
| 113 | t.datetime "updated_at", null: false |
| 114 | t.bigint "user_id", null: false |
| 115 | t.index ["repository_id", "number"], name: "index_issues_on_repository_id_and_number", unique: true |
| 116 | t.index ["repository_id"], name: "index_issues_on_repository_id" |
| 117 | t.index ["user_id"], name: "index_issues_on_user_id" |
| 118 | end |
| 119 | |
| 120 | create_table "pull_requests", force: :cascade do |t| |
| 121 | t.string "base_ref", null: false |
| 122 | t.text "body" |
| 123 | t.datetime "created_at", null: false |
| 124 | t.string "head_ref", null: false |
| 125 | t.datetime "merged_at" |
| 126 | t.integer "number", null: false |
| 127 | t.bigint "repository_id", null: false |
| 128 | t.string "state", default: "open", null: false |
| 129 | t.string "title", null: false |
| 130 | t.datetime "updated_at", null: false |
| 131 | t.bigint "user_id", null: false |
| 132 | t.index ["repository_id", "number"], name: "index_pull_requests_on_repository_id_and_number", unique: true |
| 133 | t.index ["repository_id"], name: "index_pull_requests_on_repository_id" |
| 134 | t.index ["user_id"], name: "index_pull_requests_on_user_id" |
| 135 | end |
| 136 | |
| 137 | create_table "repositories", force: :cascade do |t| |
| 138 | t.datetime "created_at", null: false |
| 139 | t.string "default_branch", default: "main", null: false |
| 140 | t.text "description" |
| 141 | t.string "disk_path", null: false |
| 142 | t.integer "downloads_count", default: 0, null: false |
| 143 | t.boolean "is_private", default: false, null: false |
| 144 | t.string "kind", default: "code", null: false |
| 145 | t.boolean "mirror", default: false, null: false |
| 146 | t.text "mirror_error" |
| 147 | t.string "mirror_status" |
| 148 | t.datetime "mirror_synced_at" |
| 149 | t.string "name", null: false |
| 150 | t.integer "stars_count", default: 0, null: false |
| 151 | t.datetime "updated_at", null: false |
| 152 | t.text "upstream_token" |
| 153 | t.string "upstream_url" |
| 154 | t.bigint "user_id", null: false |
| 155 | t.index ["kind"], name: "index_repositories_on_kind" |
| 156 | t.index ["mirror", "mirror_synced_at"], name: "index_repositories_on_mirror_and_mirror_synced_at" |
| 157 | t.index ["mirror"], name: "index_repositories_on_mirror" |
| 158 | t.index ["user_id", "name"], name: "index_repositories_on_user_id_and_name", unique: true |
| 159 | t.index ["user_id"], name: "index_repositories_on_user_id" |
| 160 | end |
| 161 | |
| 162 | create_table "repository_imports", force: :cascade do |t| |
| 163 | t.datetime "created_at", null: false |
| 164 | t.string "default_branch" |
| 165 | t.text "description" |
| 166 | t.text "error_message" |
| 167 | t.datetime "finished_at" |
| 168 | t.boolean "lfs_detected", default: false, null: false |
| 169 | t.boolean "lfs_skipped", default: false, null: false |
| 170 | t.string "mode", default: "migrate", null: false |
| 171 | t.bigint "repository_id" |
| 172 | t.string "source_host" |
| 173 | t.bigint "source_size_kb" |
| 174 | t.string "source_url", null: false |
| 175 | t.datetime "started_at" |
| 176 | t.string "status", default: "queued", null: false |
| 177 | t.string "target_name", null: false |
| 178 | t.boolean "target_private", default: false, null: false |
| 179 | t.datetime "updated_at", null: false |
| 180 | t.bigint "user_id", null: false |
| 181 | t.index ["repository_id"], name: "index_repository_imports_on_repository_id" |
| 182 | t.index ["user_id", "status"], name: "index_repository_imports_on_user_id_and_status" |
| 183 | t.index ["user_id"], name: "index_repository_imports_on_user_id" |
| 184 | end |
| 185 | |
| 186 | create_table "ssh_keys", force: :cascade do |t| |
| 187 | t.datetime "created_at", null: false |
| 188 | t.string "fingerprint", null: false |
| 189 | t.text "key_text", null: false |
| 190 | t.string "title", null: false |
| 191 | t.datetime "updated_at", null: false |
| 192 | t.bigint "user_id", null: false |
| 193 | t.index ["user_id"], name: "index_ssh_keys_on_user_id" |
| 194 | end |
| 195 | |
| 196 | create_table "stars", force: :cascade do |t| |
| 197 | t.datetime "created_at", null: false |
| 198 | t.bigint "repository_id", null: false |
| 199 | t.datetime "updated_at", null: false |
| 200 | t.bigint "user_id", null: false |
| 201 | t.index ["repository_id"], name: "index_stars_on_repository_id" |
| 202 | t.index ["user_id", "repository_id"], name: "index_stars_on_user_id_and_repository_id", unique: true |
| 203 | t.index ["user_id"], name: "index_stars_on_user_id" |
| 204 | end |
| 205 | |
| 206 | create_table "subscriptions", force: :cascade do |t| |
| 207 | t.datetime "created_at", null: false |
| 208 | t.datetime "current_period_end" |
| 209 | t.integer "plan", default: 0, null: false |
| 210 | t.integer "status", default: 0, null: false |
| 211 | t.string "stripe_customer_id" |
| 212 | t.string "stripe_subscription_id" |
| 213 | t.datetime "updated_at", null: false |
| 214 | t.bigint "user_id", null: false |
| 215 | t.index ["stripe_customer_id"], name: "index_subscriptions_on_stripe_customer_id" |
| 216 | t.index ["stripe_subscription_id"], name: "index_subscriptions_on_stripe_subscription_id" |
| 217 | t.index ["user_id"], name: "index_subscriptions_on_user_id", unique: true |
| 218 | end |
| 219 | |
| 220 | create_table "users", force: :cascade do |t| |
| 221 | t.string "access_token" |
| 222 | t.boolean "admin", default: false, null: false |
| 223 | t.string "avatar_url" |
| 224 | t.datetime "created_at", null: false |
| 225 | t.string "display_name" |
| 226 | t.string "email", null: false |
| 227 | t.string "oauth_provider" |
| 228 | t.integer "smbcloud_id", null: false |
| 229 | t.datetime "updated_at", null: false |
| 230 | t.string "username", null: false |
| 231 | t.index ["admin"], name: "index_users_on_admin_when_true", where: "(admin = true)" |
| 232 | t.index ["email"], name: "index_users_on_email", unique: true |
| 233 | t.index ["smbcloud_id"], name: "index_users_on_smbcloud_id", unique: true |
| 234 | t.index ["username"], name: "index_users_on_username", unique: true |
| 235 | end |
| 236 | |
| 237 | add_foreign_key "cloud_messages", "cloud_sessions" |
| 238 | add_foreign_key "cloud_sessions", "users" |
| 239 | add_foreign_key "cloud_usages", "users" |
| 240 | add_foreign_key "comments", "users" |
| 241 | add_foreign_key "github_connections", "users" |
| 242 | add_foreign_key "github_pr_reviews", "github_app_installations" |
| 243 | add_foreign_key "issues", "repositories" |
| 244 | add_foreign_key "issues", "users" |
| 245 | add_foreign_key "pull_requests", "repositories" |
| 246 | add_foreign_key "pull_requests", "users" |
| 247 | add_foreign_key "repositories", "users" |
| 248 | add_foreign_key "repository_imports", "repositories", on_delete: :nullify |
| 249 | add_foreign_key "repository_imports", "users" |
| 250 | add_foreign_key "ssh_keys", "users" |
| 251 | add_foreign_key "stars", "repositories" |
| 252 | add_foreign_key "stars", "users" |
| 253 | add_foreign_key "subscriptions", "users" |
| 254 | end |