Store resource

This commit is contained in:
2026-08-18 13:04:21 +02:00
parent c85148d238
commit 4dccb9a815
12 changed files with 226 additions and 1 deletions
@@ -0,0 +1,19 @@
class CreateStores < ActiveRecord::Migration[8.1]
def change
create_table :stores, id: { type: :bigint, unsigned: true },
charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci",
if_not_exists: true do |t|
# A store is a WarpEngine catalog plus the repository that configures a
# client for it. The registry lives here rather than in the engine: the
# engine serves one catalog and knows nothing about who ships stores for it.
t.string :name, null: false
t.string :catalog_url, null: false
t.string :store_repository_url, null: false
t.datetime :deleted_at, precision: 3
t.timestamps precision: 3
t.index :deleted_at, name: "idx_stores_deleted_at"
t.index :name, name: "idx_stores_name"
end
end
end
+12 -1
View File
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[8.1].define(version: 2026_08_06_000002) do
ActiveRecord::Schema[8.1].define(version: 2026_08_18_000001) do
create_table "admin_users", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.datetime "created_at", null: false
t.datetime "deleted_at", precision: 3
@@ -281,6 +281,17 @@ ActiveRecord::Schema[8.1].define(version: 2026_08_06_000002) do
t.index ["owner_type", "owner_id"], name: "idx_softwares_owner"
end
create_table "stores", id: { type: :bigint, unsigned: true }, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.string "catalog_url", null: false
t.datetime "created_at", precision: 3, null: false
t.datetime "deleted_at", precision: 3
t.string "name", null: false
t.string "store_repository_url", null: false
t.datetime "updated_at", precision: 3, null: false
t.index ["deleted_at"], name: "idx_stores_deleted_at"
t.index ["name"], name: "idx_stores_name"
end
add_foreign_key "admin_users", "members"
add_foreign_key "downloads", "releases", name: "fk_downloads_release", on_delete: :nullify
add_foreign_key "external_links", "softwares", name: "fk_softwares_external_links", on_delete: :cascade
+11
View File
@@ -15,3 +15,14 @@ end
m.avatar_filename = attrs[:avatar_filename]
end
end
# The store registry the graphical desktop client reads. Our own catalog is the
# first record; anyone running this site would add their own the same way, from
# the admin panel or here.
Store.find_or_create_by!(name: "Teletype Games") do |store|
store.catalog_url = ENV.fetch("STORE_CATALOG_URL", "https://teletypegames.org")
store.store_repository_url = ENV.fetch(
"STORE_REPOSITORY_URL",
"https://git.teletypegames.org/stores/ttg-desktop-store"
)
end