Files
aggios.app/postgres/migrations/015_create_template_solutions.sql
2025-12-17 13:36:23 -03:00

17 lines
905 B
SQL

-- Migration: Vincular Signup Templates com Solutions
-- Permite que ao criar um link de cadastro personalizado, o superadmin
-- selecione quais soluções estarão disponíveis para as agências que se cadastrarem
CREATE TABLE IF NOT EXISTS template_solutions (
template_id UUID NOT NULL REFERENCES agency_signup_templates(id) ON DELETE CASCADE,
solution_id UUID NOT NULL REFERENCES solutions(id) ON DELETE CASCADE,
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (template_id, solution_id)
);
-- Index para queries rápidas
CREATE INDEX idx_template_solutions_template ON template_solutions(template_id);
CREATE INDEX idx_template_solutions_solution ON template_solutions(solution_id);
COMMENT ON TABLE template_solutions IS 'Relacionamento N:N entre signup templates e solutions - define quais soluções estarão disponíveis ao cadastrar via template';