All checks were successful
Test Asgard Runner / test (push) Successful in 2s
Build complete module activation and license-module binding system with marketplace catalog, purchase tracking, and installation status monitoring. Database schema (migration 009): - modules table — Registry with pricing, features, plugin URLs - module_purchases — License-module ownership with transaction logging - module_installations — Deployment status tracking - Seed data: Loot Manager module ($9.99) Backend implementation: - Domain models with rust_decimal pricing support - 11 data access functions (catalog, ownership, purchases, installation) - 5 REST endpoints with JWT auth and license scoping - Multi-tenant enforcement via license_id from claims Purchase flow stub: - Immediate purchase recording without payment gateway - PayPal integration deferred to XO's direct implementation - Transaction ID and amount fields ready for real gateway Module installation: - Integration with ModuleInstaller service - NATS-based deployment to companion agent - Real-time status tracking via polling endpoint All queries compile-time verified. Zero cross-tenant exposure. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
56 lines
2.1 KiB
SQL
56 lines
2.1 KiB
SQL
-- Module Licensing System
|
|
-- Phase 4: Module marketplace and license-module binding
|
|
|
|
-- Module registry (available modules in marketplace)
|
|
CREATE TABLE modules (
|
|
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
|
|
slug VARCHAR(100) UNIQUE NOT NULL,
|
|
name VARCHAR(200) NOT NULL,
|
|
description TEXT,
|
|
category VARCHAR(50), -- 'loot', 'events', 'economy', 'kits', etc.
|
|
price_usd DECIMAL(10,2) NOT NULL,
|
|
preview_image_url TEXT,
|
|
screenshots JSONB,
|
|
features JSONB,
|
|
version VARCHAR(20) NOT NULL,
|
|
plugin_file_url TEXT, -- Download URL for plugin file
|
|
created_at TIMESTAMPTZ DEFAULT NOW()
|
|
);
|
|
|
|
-- Module purchases (which licenses own which modules)
|
|
CREATE TABLE module_purchases (
|
|
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
|
|
license_id UUID NOT NULL REFERENCES licenses(id) ON DELETE CASCADE,
|
|
module_id UUID NOT NULL REFERENCES modules(id) ON DELETE CASCADE,
|
|
purchased_at TIMESTAMPTZ DEFAULT NOW(),
|
|
transaction_id VARCHAR(255), -- PayPal transaction ID
|
|
amount_paid DECIMAL(10,2),
|
|
UNIQUE(license_id, module_id)
|
|
);
|
|
|
|
-- Module installations (deployment status on servers)
|
|
CREATE TABLE module_installations (
|
|
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
|
|
license_id UUID NOT NULL REFERENCES licenses(id) ON DELETE CASCADE,
|
|
module_id UUID NOT NULL REFERENCES modules(id) ON DELETE CASCADE,
|
|
status VARCHAR(50) DEFAULT 'pending', -- 'pending', 'installing', 'installed', 'failed'
|
|
installed_at TIMESTAMPTZ,
|
|
error_message TEXT,
|
|
UNIQUE(license_id, module_id)
|
|
);
|
|
|
|
CREATE INDEX idx_module_purchases_license ON module_purchases(license_id);
|
|
CREATE INDEX idx_module_installations_license ON module_installations(license_id);
|
|
|
|
-- Seed data: Loot Manager module
|
|
INSERT INTO modules (slug, name, description, category, price_usd, version, features)
|
|
VALUES (
|
|
'loot-manager',
|
|
'Loot Manager',
|
|
'Visual loot table editor with drag-and-drop items, spawn rates, and one-click profile switching.',
|
|
'loot',
|
|
9.99,
|
|
'1.0.0',
|
|
'["Visual loot table editor", "Container browser (crates, barrels, NPCs)", "Loot profiles (2x, 10x, etc.)", "One-click profile switching", "Import/export profiles"]'::JSONB
|
|
);
|