Hub 2.0 step 1: products foundation
- Product enum (events, accounts, website, app) on Licence and Install, Install.publicKey; existing rows are events - One open licence per product per customer: partial unique index, with a migration guard that names customers with duplicates (npm run check:hub2 lists them beforehand) - Licence keys per product (CEH-, CCA-, CCW-, CCP-); free Accounts licence created with the first other product licence - Protocol v1 registers Events licences only (409 WRONG_PRODUCT); only Events licences can be invoiced until billing per customer - Cross Code Hub in the UI, emails and PDFs - @crosscode/contracts 1.0.0 vendored (backend/vendor) - Steps merge into release/2.0, not main (plan updated) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -56,12 +56,25 @@ enum LicenceStatus {
|
||||
revoked
|
||||
}
|
||||
|
||||
// Hub 2.0: the Cross Code products a church can have (ROADMAP-v3 §5). Accounts comes free with
|
||||
// any other product.
|
||||
enum Product {
|
||||
events
|
||||
accounts
|
||||
website
|
||||
app
|
||||
}
|
||||
|
||||
model Licence {
|
||||
id String @id @default(uuid())
|
||||
customerId String
|
||||
customer Customer @relation(fields: [customerId], references: [id], onDelete: Restrict)
|
||||
// CEH-XXXX-XXXX-XXXX-XXXX, generated by the Hub.
|
||||
// CEH-XXXX-XXXX-XXXX-XXXX (Events), CCA- (Accounts), CCW- (Website), CCP- (App).
|
||||
key String @unique
|
||||
// Hub 2.0. A customer has at most one licence per product that isn't revoked: enforced by the
|
||||
// partial unique index "Licence_customerId_product_open_key" (migration 20261104…_products),
|
||||
// which Prisma can't express here.
|
||||
product Product @default(events)
|
||||
plan String @default("standard")
|
||||
status LicenceStatus @default(active)
|
||||
// Null = no end date.
|
||||
@@ -90,6 +103,8 @@ model Licence {
|
||||
install Install?
|
||||
invoices Invoice[]
|
||||
licenceChanges LicenceChange[]
|
||||
|
||||
@@index([customerId, product])
|
||||
}
|
||||
|
||||
enum BillingCycle {
|
||||
@@ -104,8 +119,12 @@ model Install {
|
||||
customer Customer @relation(fields: [customerId], references: [id], onDelete: Restrict)
|
||||
licenceId String? @unique
|
||||
licence Licence? @relation(fields: [licenceId], references: [id], onDelete: SetNull)
|
||||
// Hub 2.0: the licence's product, set when the install registers.
|
||||
product Product @default(events)
|
||||
name String
|
||||
url String
|
||||
// Protocol v2: the install's Ed25519 public key (PEM), shared with its linked products.
|
||||
publicKey String?
|
||||
// The install's HMAC secret, AES-GCM encrypted: the Hub needs it to check signatures.
|
||||
secret String
|
||||
version String?
|
||||
|
||||
Reference in New Issue
Block a user