

CREATE TABLE IF NOT EXISTS templates (
  id INT AUTO_INCREMENT PRIMARY KEY,
  name VARCHAR(100) NOT NULL,
  memory INT NOT NULL DEFAULT 1024,
  swap INT NOT NULL DEFAULT 0,
  disk INT NOT NULL DEFAULT 0,
  io_weight INT NOT NULL DEFAULT 500,
  cpu INT NOT NULL DEFAULT 0,
  databases_limit INT NOT NULL DEFAULT 0,
  allocations_limit INT NOT NULL DEFAULT 0,
  backups_limit INT NOT NULL DEFAULT 0,
  created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
);

CREATE TABLE IF NOT EXISTS managed_servers (
  id INT AUTO_INCREMENT PRIMARY KEY,
  ptero_server_id INT NOT NULL,
  ptero_identifier VARCHAR(20),
  server_name VARCHAR(120) NOT NULL,
  user_email VARCHAR(160),
  expires_at DATETIME NULL,
  status ENUM('active','expired','suspended','deleted') NOT NULL DEFAULT 'active',
  created_by INT NULL,
  created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
);
-- login default: owner / owner123

INSERT IGNORE INTO templates (id, name, memory, swap, disk, io_weight, cpu, databases_limit, allocations_limit, backups_limit) VALUES
(1, '1GB Unlimited', 1024, 0, 0, 500, 0, 0, 0, 0),
(2, '2GB Unlimited', 2048, 0, 0, 500, 0, 0, 0, 0),
(3, '4GB Unlimited', 4096, 0, 0, 500, 0, 0, 0, 0);
