5697137c52
The "permit/lejet" feature is really a subscription. Full rename of the mutable master data, plus a recurring monthly price. - DB (migration 0004, data-preserving ALTER RENAME): permits→subscriptions, permit_credentials/_plates→subscription_*, sessions.permit_id→subscription_id. - Pricing: per-subscription priceMinor + period(monthly) + currency, with a site default (site_config.subscription_monthly_price_minor) pre-filling the form. - Server: subscription-flow.ts (SubscriptionFlow), routes/subscriptions.ts (/api/subscriptions). Web: SubscriptionManager, route, i18n (sq Abonimet/en). - The signed ledger `permitId` payload is intentionally kept — immutable hash-chained history; renaming it would break verification of past events. Deferred (wiki notes): fee collection into the ledger/shift (a shift-attributed payment), LPR/ANPR plate source, time-of-day access windows (overnight subscriber). Also carries the device-footer UI surface (api DeviceStatus, router mount, i18n devices) due to shared-file overlap with the preceding footer commit. Verified end-to-end on a fresh DB and migration on a live-DB copy (sessions preserved). Live DB migrated. Full monorepo builds clean. Claude-Session: https://claude.ai/code/session_01Xcm6ikLgGoCxxHrxtjkk5V
26 lines
1.3 KiB
SQL
26 lines
1.3 KiB
SQL
-- Rename permit → subscription (master data only). The signed ledger keeps its
|
|
-- immutable `permitId` payload — NOT touched here. Data-preserving ALTER RENAMEs
|
|
-- (SQLite 3.25+) rather than drop/recreate, so existing subscriptions survive.
|
|
-- Adds per-subscription pricing (price_minor + period + currency) and a site-wide
|
|
-- default monthly price. See wiki/entities/subscription.md.
|
|
|
|
ALTER TABLE `permits` RENAME TO `subscriptions`;
|
|
--> statement-breakpoint
|
|
ALTER TABLE `permit_credentials` RENAME TO `subscription_credentials`;
|
|
--> statement-breakpoint
|
|
ALTER TABLE `subscription_credentials` RENAME COLUMN `permit_id` TO `subscription_id`;
|
|
--> statement-breakpoint
|
|
ALTER TABLE `permit_plates` RENAME TO `subscription_plates`;
|
|
--> statement-breakpoint
|
|
ALTER TABLE `subscription_plates` RENAME COLUMN `permit_id` TO `subscription_id`;
|
|
--> statement-breakpoint
|
|
ALTER TABLE `subscriptions` ADD `price_minor` integer;
|
|
--> statement-breakpoint
|
|
ALTER TABLE `subscriptions` ADD `period` text DEFAULT 'monthly' NOT NULL;
|
|
--> statement-breakpoint
|
|
ALTER TABLE `subscriptions` ADD `currency` text;
|
|
--> statement-breakpoint
|
|
ALTER TABLE `sessions` RENAME COLUMN `permit_id` TO `subscription_id`;
|
|
--> statement-breakpoint
|
|
ALTER TABLE `site_config` ADD `subscription_monthly_price_minor` integer;
|