From 9d9192f68191146df99d03626f8483b459b89532 Mon Sep 17 00:00:00 2001 From: Jon Staab Date: Mon, 25 May 2026 16:15:00 -0700 Subject: [PATCH] Remove redundant relay.schema field --- backend/README.md | 2 +- backend/migrations/0001_init.sql | 1 - backend/spec/api.md | 2 +- backend/spec/infra.md | 2 +- backend/spec/models.md | 1 - backend/src/command.rs | 8 +++----- backend/src/infra.rs | 4 ++-- backend/src/models.rs | 2 -- backend/src/routes/relays.rs | 1 - frontend/src/lib/api.ts | 1 - 10 files changed, 8 insertions(+), 16 deletions(-) diff --git a/backend/README.md b/backend/README.md index 5093f0a..6791d53 100644 --- a/backend/README.md +++ b/backend/README.md @@ -72,7 +72,7 @@ All configuration is read from the environment by `Env::load()` at startup. **Ev | `LIVEKIT_API_KEY` | LiveKit API key sent to zooid | | `LIVEKIT_API_SECRET` | LiveKit API secret sent to zooid | -**Blossom S3** — sent to zooid as the S3 adapter config (with `key_prefix` = relay schema) when a relay enables blossom. +**Blossom S3** — sent to zooid as the S3 adapter config (with `key_prefix` = relay id) when a relay enables blossom. | Variable | Description | | ----------------------- | --------------------- | diff --git a/backend/migrations/0001_init.sql b/backend/migrations/0001_init.sql index c5d1470..e65805a 100644 --- a/backend/migrations/0001_init.sql +++ b/backend/migrations/0001_init.sql @@ -20,7 +20,6 @@ CREATE TABLE IF NOT EXISTS tenant ( CREATE TABLE IF NOT EXISTS relay ( id TEXT PRIMARY KEY, tenant TEXT NOT NULL, - schema TEXT NOT NULL, subdomain TEXT NOT NULL UNIQUE, plan TEXT NOT NULL, status TEXT NOT NULL, diff --git a/backend/spec/api.md b/backend/spec/api.md index 475b052..6161fee 100644 --- a/backend/spec/api.md +++ b/backend/spec/api.md @@ -143,7 +143,7 @@ Handlers take `State>`, an optional `AuthedPubkey`, then path/query/bod ## `create_relay` — `POST /relays` - Admin or the `tenant` pubkey in the request body -- Generates the relay `id`/`schema`, validates and normalizes the relay via `prepare_relay`, and creates it via `command.create_relay` +- Generates the relay `id`, validates and normalizes the relay via `prepare_relay`, and creates it via `command.create_relay` - Duplicate subdomain → `422` `subdomain-exists` - `data` is the relay; HTTP `201` diff --git a/backend/spec/infra.md b/backend/spec/infra.md index aa081e9..2262fab 100644 --- a/backend/spec/infra.md +++ b/backend/spec/infra.md @@ -45,7 +45,7 @@ Members: - A relay is "new" only if it has never completed a sync (`synced != 1` and no `complete_relay_sync` activity exists). New relays are created with `POST /relay/:id`; existing relays are updated with `PATCH /relay/:id`. - A freshly generated `secret` is included only for creation (`POST`), so updates don't rotate relay identity and we never store the secret. - The body carries relay configuration: `host` (= `subdomain.relay_domain`), `schema`, `inactive` (true when status is `inactive` or `delinquent`), `info` (name/icon/description/pubkey), `policy`, `groups`, `management`, `blossom`, `livekit`, `push`, and hard-coded `roles`. -- When `blossom_enabled`, the blossom section uses `adapter: "s3"` with the `BLOSSOM_S3_*` settings and `s3.key_prefix` set to the relay's `schema`; otherwise it sends `{ "enabled": false }`. +- When `blossom_enabled`, the blossom section uses `adapter: "s3"` with the `BLOSSOM_S3_*` settings and `s3.key_prefix` set to the relay's `id`; otherwise it sends `{ "enabled": false }`. - When `livekit_enabled`, the livekit section carries the `LIVEKIT_*` settings; otherwise `{ "enabled": false }`. ## `pub async fn list_relay_members(&self, relay_id: &str) -> Result>` diff --git a/backend/spec/models.md b/backend/spec/models.md index 139a485..f78053a 100644 --- a/backend/spec/models.md +++ b/backend/spec/models.md @@ -66,7 +66,6 @@ A relay is a nostr relay owned by a `tenant` and hosted by the attached zooid in - `id` - calculated based on `subdomain` (with `-` replaced by `_`) + `_` + 8 random hex chars - `tenant` - the tenant's pubkey -- `schema` - the relay's db schema (read only, same as `id`) - `subdomain` - the relay's subdomain - `plan` - the relay's plan - `status` - one of `active|inactive|delinquent`. Only `active` relays count toward billing. `delinquent` is set by the billing system when a relay's subscription becomes past due; `inactive` is set when a user or admin manually deactivates a relay. diff --git a/backend/src/command.rs b/backend/src/command.rs index f457ba8..bd81b8c 100644 --- a/backend/src/command.rs +++ b/backend/src/command.rs @@ -177,16 +177,15 @@ impl Command { self.with_activity("create_relay", "relay", &relay.id, async |tx| { sqlx::query( "INSERT INTO relay ( - id, tenant, schema, subdomain, plan, status, synced, sync_error, + id, tenant, subdomain, plan, status, synced, sync_error, info_name, info_icon, info_description, policy_public_join, policy_strip_signatures, groups_enabled, management_enabled, blossom_enabled, livekit_enabled, push_enabled - ) VALUES (?, ?, ?, ?, ?, 'active', 0, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", + ) VALUES (?, ?, ?, ?, 'active', 0, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", ) .bind(&relay.id) .bind(&relay.tenant) - .bind(&relay.schema) .bind(&relay.subdomain) .bind(&relay.plan) .bind(&relay.sync_error) @@ -211,7 +210,7 @@ impl Command { self.with_activity("update_relay", "relay", &relay.id, async |tx| { sqlx::query( "UPDATE relay - SET tenant = ?, schema = ?, subdomain = ?, plan = ?, status = ?, sync_error = ?, synced = 0, + SET tenant = ?, subdomain = ?, plan = ?, status = ?, sync_error = ?, synced = 0, info_name = ?, info_icon = ?, info_description = ?, policy_public_join = ?, policy_strip_signatures = ?, groups_enabled = ?, management_enabled = ?, blossom_enabled = ?, @@ -219,7 +218,6 @@ impl Command { WHERE id = ?", ) .bind(&relay.tenant) - .bind(&relay.schema) .bind(&relay.subdomain) .bind(&relay.plan) .bind(&relay.status) diff --git a/backend/src/infra.rs b/backend/src/infra.rs index 9177d77..7d05006 100644 --- a/backend/src/infra.rs +++ b/backend/src/infra.rs @@ -185,7 +185,7 @@ impl Infra { let mut body = serde_json::json!({ "host": format!("{}.{}", relay.subdomain, self.env.relay_domain), - "schema": relay.schema, + "schema": relay.id, "inactive": relay.status == RELAY_STATUS_INACTIVE || relay.status == RELAY_STATUS_DELINQUENT, "info": { @@ -210,7 +210,7 @@ impl Infra { "bucket": self.env.blossom_s3_bucket, "access_key": self.env.blossom_s3_access_key, "secret_key": self.env.blossom_s3_secret_key, - "key_prefix": relay.schema, + "key_prefix": relay.id, }, }) } else { diff --git a/backend/src/models.rs b/backend/src/models.rs index a2149cd..b8eb1e4 100644 --- a/backend/src/models.rs +++ b/backend/src/models.rs @@ -52,7 +52,6 @@ pub struct LightningInvoice { pub struct Relay { pub id: String, pub tenant: String, - pub schema: String, pub subdomain: String, pub plan: String, pub status: String, @@ -75,7 +74,6 @@ impl Default for Relay { Self { id: String::new(), tenant: String::new(), - schema: String::new(), subdomain: String::new(), plan: String::new(), status: RELAY_STATUS_ACTIVE.to_string(), diff --git a/backend/src/routes/relays.rs b/backend/src/routes/relays.rs index 50d2215..8f96752 100644 --- a/backend/src/routes/relays.rs +++ b/backend/src/routes/relays.rs @@ -114,7 +114,6 @@ pub async fn create_relay( let relay = Relay { id: relay_id.clone(), tenant: payload.tenant, - schema: relay_id.clone(), subdomain: payload.subdomain, plan: payload.plan, info_name: payload.info_name, diff --git a/frontend/src/lib/api.ts b/frontend/src/lib/api.ts index cc9957c..f2423f1 100644 --- a/frontend/src/lib/api.ts +++ b/frontend/src/lib/api.ts @@ -46,7 +46,6 @@ export type PlanId = string export type Relay = { id: string tenant: string - schema: string subdomain: string plan: PlanId status: string