omnichannel-deploy/database/migrations/009_customer_contacts.sql

19 lines
705 B
MySQL
Raw Permalink Normal View History

-- ============================================================
-- Migration 009: Agenda de contatos dos clientes
-- Tabela: customer_contacts
-- ============================================================
CREATE TABLE IF NOT EXISTS customer_contacts (
chat_id VARCHAR(255) PRIMARY KEY,
phone VARCHAR(80) NOT NULL,
name VARCHAR(255),
company VARCHAR(255),
note TEXT,
updated_by_user_id INTEGER REFERENCES usuarios(id) ON DELETE SET NULL,
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX IF NOT EXISTS idx_customer_contacts_updated_at
ON customer_contacts (updated_at DESC);