-- Module configuration table for enabling/disabling feature modules

CREATE TABLE module_config (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  slug VARCHAR(50) NOT NULL UNIQUE,
  name VARCHAR(100) NOT NULL,
  description TEXT,
  licensed BOOLEAN NOT NULL DEFAULT true,
  enabled BOOLEAN NOT NULL DEFAULT false,
  created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
  updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
);

-- Seed default modules
INSERT INTO module_config (slug, name, description, licensed, enabled) VALUES
  ('inventory', 'Inventory', 'Product catalog, stock tracking, and unit management', true, true),
  ('pos', 'Point of Sale', 'Sales transactions, cash drawer, and receipts', true, true),
  ('repairs', 'Repairs', 'Repair ticket management, batches, and service templates', true, true),
  ('rentals', 'Rentals', 'Instrument rental agreements and billing', true, false),
  ('lessons', 'Lessons', 'Lesson scheduling, instructor management, and billing', true, false),
  ('files', 'Files', 'Shared file storage with folder organization', true, true),
  ('vault', 'Vault', 'Encrypted password and secret manager', true, true),
  ('email', 'Email', 'Email campaigns, templates, and sending', true, false),
  ('reports', 'Reports', 'Business reports and data export', true, true);
