39 lines
1.5 KiB
SQL
39 lines
1.5 KiB
SQL
-- Agency Signup Templates (SuperAdmin → Agencies)
|
|
CREATE TABLE IF NOT EXISTS agency_signup_templates (
|
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
name VARCHAR(255) NOT NULL,
|
|
slug VARCHAR(100) UNIQUE NOT NULL,
|
|
description TEXT,
|
|
|
|
-- Campos do formulário (JSONB com campos habilitados/desabilitados)
|
|
form_fields JSONB NOT NULL DEFAULT '[]',
|
|
|
|
-- Módulos disponíveis para a agência
|
|
available_modules JSONB NOT NULL DEFAULT '[]',
|
|
|
|
-- Personalização
|
|
custom_primary_color VARCHAR(7),
|
|
custom_logo_url TEXT,
|
|
|
|
-- Redirecionamento após cadastro
|
|
redirect_url TEXT,
|
|
success_message TEXT,
|
|
|
|
-- Controle
|
|
is_active BOOLEAN DEFAULT true,
|
|
usage_count INTEGER DEFAULT 0,
|
|
max_uses INTEGER,
|
|
expires_at TIMESTAMP WITH TIME ZONE,
|
|
|
|
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
|
|
-- Index para busca rápida por slug
|
|
CREATE INDEX idx_agency_templates_slug ON agency_signup_templates(slug);
|
|
CREATE INDEX idx_agency_templates_active ON agency_signup_templates(is_active);
|
|
|
|
COMMENT ON TABLE agency_signup_templates IS 'Templates de cadastro de agências (SuperAdmin → Agências)';
|
|
COMMENT ON COLUMN agency_signup_templates.form_fields IS 'Campos do formulário em JSONB: [{"name": "cnpj", "required": true, "enabled": true}]';
|
|
COMMENT ON COLUMN agency_signup_templates.available_modules IS 'Módulos disponíveis: ["CRM", "Financial", "Projects"]';
|