L'utente ha un hosting Virtualmin esistente (musictools.djluza.com)
con Apache + Node 20 + MariaDB + PM2. Tutta l'infrastruttura
Cloudflare (Workers/D1/R2/Pages) e' rimpiazzata con un backend
Express che gira sul server gia' presente, a costo zero.
Cambia:
- server/src/*.ts (Workers) -> server/src/*.js (Node ESM puro)
- D1 (sqlite) -> MariaDB 10.11 via mysql2/promise
- R2 (storage) -> filesystem locale ~/builds/ + signed URL HMAC
- wrangler.toml -> ecosystem.config.cjs (PM2)
- Aggiunto src/migrate.js: runner SQL idempotente
Endpoints invariati - l'app desktop non vede differenze:
- POST /api/license/{activate,validate,deactivate}
- GET /api/latest, /api/download
- POST /api/webhook/lemonsqueezy
- GET /api/health
README riscritto con istruzioni complete: creazione DB,
deploy via rsync/git, config Apache reverse proxy via
Virtualmin, gestione PM2, backup, workflow release.
Email rimane su Resend (deliverability) - free tier sufficiente.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
50 lines
1.9 KiB
SQL
50 lines
1.9 KiB
SQL
-- Schema MariaDB iniziale per MusicTools licenze.
|
|
-- Tutto utf8mb4 + InnoDB con FK abilitate.
|
|
|
|
SET NAMES utf8mb4;
|
|
|
|
CREATE TABLE IF NOT EXISTS licenses (
|
|
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
|
license_key VARCHAR(64) NOT NULL,
|
|
email VARCHAR(255) NOT NULL,
|
|
status ENUM('active','revoked','refunded') NOT NULL DEFAULT 'active',
|
|
source VARCHAR(32) NULL,
|
|
order_id VARCHAR(64) NULL,
|
|
created_at BIGINT UNSIGNED NOT NULL,
|
|
updated_at BIGINT UNSIGNED NOT NULL,
|
|
PRIMARY KEY (id),
|
|
UNIQUE KEY uq_licenses_key (license_key),
|
|
KEY idx_licenses_email (email),
|
|
KEY idx_licenses_order_id (order_id)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
CREATE TABLE IF NOT EXISTS activations (
|
|
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
|
license_id INT UNSIGNED NOT NULL,
|
|
device_id VARCHAR(64) NOT NULL,
|
|
device_name VARCHAR(255) NULL,
|
|
app_version VARCHAR(32) NULL,
|
|
activated_at BIGINT UNSIGNED NOT NULL,
|
|
last_seen_at BIGINT UNSIGNED NOT NULL,
|
|
revoked_at BIGINT UNSIGNED NULL,
|
|
PRIMARY KEY (id),
|
|
UNIQUE KEY uq_activations_lic_dev (license_id, device_id),
|
|
KEY idx_activations_license (license_id),
|
|
CONSTRAINT fk_activations_license
|
|
FOREIGN KEY (license_id) REFERENCES licenses(id) ON DELETE CASCADE
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
CREATE TABLE IF NOT EXISTS releases (
|
|
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
|
version VARCHAR(32) NOT NULL,
|
|
platform ENUM('macos','windows') NOT NULL,
|
|
file_path VARCHAR(512) NOT NULL,
|
|
size_bytes BIGINT UNSIGNED NULL,
|
|
sha256 CHAR(64) NULL,
|
|
notes TEXT NULL,
|
|
published_at BIGINT UNSIGNED NOT NULL,
|
|
PRIMARY KEY (id),
|
|
UNIQUE KEY uq_releases_ver_plat (version, platform),
|
|
KEY idx_releases_platform_pub (platform, published_at DESC)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|