
CREATE DATABASE IF NOT EXISTS telemarketing;
USE telemarketing;

CREATE TABLE database_nasabah(
id INT AUTO_INCREMENT PRIMARY KEY,
uid VARCHAR(50),
nama VARCHAR(150),
no_tlp VARCHAR(20),
assigned_to VARCHAR(100),
status ENUM('belum','selesai') DEFAULT 'belum',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

CREATE TABLE followups(
id INT AUTO_INCREMENT PRIMARY KEY,
uid VARCHAR(50),
nasabah_id INT,
user VARCHAR(100),
keterangan VARCHAR(100),
tanggal TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

CREATE TABLE pengaturan_keterangan(
id INT AUTO_INCREMENT PRIMARY KEY,
uid VARCHAR(50),
nama_keterangan VARCHAR(100)
);

CREATE TABLE tokens(
id INT AUTO_INCREMENT PRIMARY KEY,
uid VARCHAR(50),
token_code VARCHAR(100),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

CREATE TABLE token_history(
id INT AUTO_INCREMENT PRIMARY KEY,
uid VARCHAR(50),
user VARCHAR(100),
token_code VARCHAR(100),
valid_until DATETIME,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

INSERT INTO pengaturan_keterangan(uid,nama_keterangan) VALUES
(UUID(),'Tidak Aktif'),
(UUID(),'Tidak Mau'),
(UUID(),'Tidak Diangkat'),
(UUID(),'Salah Sambung');
