CREATE DATABASE IF NOT EXISTS cmseg_cloud CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
USE cmseg_cloud;
CREATE TABLE IF NOT EXISTS backups (
  id INT AUTO_INCREMENT PRIMARY KEY,
  device VARCHAR(120) NOT NULL,
  sent_at VARCHAR(60) NULL,
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  payload LONGTEXT NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS config (
  name VARCHAR(80) PRIMARY KEY,
  value TEXT NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
INSERT INTO config(name,value) VALUES ('sync_token','cmseg123') ON DUPLICATE KEY UPDATE value=value;
