CRM de WhatsApp, Instagram, Messenger y TikTok de Wachato, basado en Vocero CRM (MIT), listo para desplegar un negocio por instancia: - Marca blanca: nombre, color, moneda y giro del negocio desde el .env (BRAND_NAME, BRAND_ACCENT, BRAND_CURRENCY, BUSINESS_DESCRIPTION); se aplican una vez y luego manda Ajustes → Marca. - Superadmin sembrado al arrancar (SUPERADMIN_*), idempotente. - Servicios y precios, campos personalizados, exportación a Excel/PDF, respaldos, agenda, atribución de anuncios y transcripción de notas de voz. - Diseño con contraste AAA, tema claro y oscuro. - Despliegue: docker compose (Caddy opcional), plantillas para paneles con reverse proxy (deploy/aapanel), imagen publicada en GHCR por la CI. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
53 lines
3.1 KiB
SQL
53 lines
3.1 KiB
SQL
CREATE TABLE "custom_field" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"organization_id" text NOT NULL,
|
|
"target_entity" text DEFAULT 'contact' NOT NULL,
|
|
"key" text NOT NULL,
|
|
"label" text NOT NULL,
|
|
"field_type" text NOT NULL,
|
|
"options" jsonb DEFAULT '[]'::jsonb NOT NULL,
|
|
"required" boolean DEFAULT false NOT NULL,
|
|
"position" integer DEFAULT 0 NOT NULL,
|
|
"created_at" timestamp DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "custom_field_value" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"organization_id" text NOT NULL,
|
|
"field_id" text NOT NULL,
|
|
"entity_id" text NOT NULL,
|
|
"value" jsonb,
|
|
"updated_at" timestamp DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE "service_item" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"organization_id" text NOT NULL,
|
|
"category" text NOT NULL,
|
|
"name" text NOT NULL,
|
|
"description" text,
|
|
"specifications" text,
|
|
"pricing_type" text DEFAULT 'quote_required' NOT NULL,
|
|
"price_cents" integer,
|
|
"currency" text DEFAULT 'MXN' NOT NULL,
|
|
"unit_label" text,
|
|
"delivery_time" text,
|
|
"is_active" boolean DEFAULT true NOT NULL,
|
|
"position" integer DEFAULT 0 NOT NULL,
|
|
"created_at" timestamp DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp DEFAULT now() NOT NULL,
|
|
CONSTRAINT "service_item_price_ck" CHECK ("service_item"."price_cents" is null or "service_item"."price_cents" >= 0)
|
|
);
|
|
--> statement-breakpoint
|
|
ALTER TABLE "contact" ADD COLUMN "tags" jsonb DEFAULT '[]'::jsonb NOT NULL;--> statement-breakpoint
|
|
ALTER TABLE "pipeline_stage" ADD COLUMN "capi_event" text;--> statement-breakpoint
|
|
ALTER TABLE "custom_field" ADD CONSTRAINT "custom_field_organization_id_organization_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "custom_field_value" ADD CONSTRAINT "custom_field_value_organization_id_organization_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "custom_field_value" ADD CONSTRAINT "custom_field_value_field_id_custom_field_id_fk" FOREIGN KEY ("field_id") REFERENCES "public"."custom_field"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "service_item" ADD CONSTRAINT "service_item_organization_id_organization_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
CREATE UNIQUE INDEX "custom_field_org_entity_key_uq" ON "custom_field" USING btree ("organization_id","target_entity","key");--> statement-breakpoint
|
|
CREATE INDEX "custom_field_org_pos_idx" ON "custom_field" USING btree ("organization_id","position");--> statement-breakpoint
|
|
CREATE UNIQUE INDEX "custom_field_value_field_entity_uq" ON "custom_field_value" USING btree ("field_id","entity_id");--> statement-breakpoint
|
|
CREATE INDEX "custom_field_value_org_entity_idx" ON "custom_field_value" USING btree ("organization_id","entity_id");--> statement-breakpoint
|
|
CREATE INDEX "service_item_org_pos_idx" ON "service_item" USING btree ("organization_id","position"); |