#CREATE USER 'agents-db-user'@'localhost' IDENTIFIED BY '';
#FLUSH PRIVILEGES;


CREATE TABLE `auth_org` (
  `orgID` int NOT NULL AUTO_INCREMENT,
  orgName varchar(300) not null,
  ownerUserID int not null,
  `createdDate` datetime NOT NULL default NOW(),
  `modifiedDate` datetime NOT NULL default NOW(),
  PRIMARY KEY (`orgID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


CREATE TABLE `auth_user_master` (
  `masterUserID` int NOT NULL AUTO_INCREMENT,
  orgID int,
  orgRole varchar(50) default 'admin',
  username varchar(300) not null,
  userEmail varchar(300) not null,
  `userGuid` varchar(300) NOT NULL,
  `authToken` varchar(300) NOT NULL,
  provider varchar(300) not null,
  userImgPrefix  varchar(50) NOT NULL default 'blank-avatar',
  `createdDate` datetime NOT NULL default NOW(),
  `modifiedDate` datetime NOT NULL default NOW(),
  PRIMARY KEY (`masterUserID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;




CREATE TABLE `agents` (
  `agentID` int NOT NULL AUTO_INCREMENT,
  userID int not null,
  `agentName` varchar(50) NOT NULL,
  `agentTitle` varchar(50) NOT NULL,
  agentImgPrefix varchar(50) NOT NULL,
  `agentType` varchar(50) NOT NULL,
  `agentRole` varchar(50) NOT NULL,
  `agentDescription` varchar(300) NOT NULL,
  agentStatus varchar(100) NOT NULL default 'Active',
  PRIMARY KEY (`agentID`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;



CREATE TABLE `agent_prompts` (
  `promptID` int NOT NULL AUTO_INCREMENT,
  agentID int not null,
  `promptTitle` varchar(50) NOT NULL,
  `prompt` text NOT NULL,
  promptType varchar(50) not null default 'pre-prompt',
  promptOrder int not null default 0,
  promptStatus varchar(100) NOT NULL default 'Active',
  PRIMARY KEY (`promptID`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;




CREATE TABLE `agent_files` (
  `agentFileID` int NOT NULL AUTO_INCREMENT,
  agentID int not null,
  fileName varchar(100) NOT NULL,
  alwaysInclude varchar(100) NOT NULL default 'Active',
  PRIMARY KEY (`agentFileID`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;



CREATE TABLE `chats` (
  `chatID` int NOT NULL AUTO_INCREMENT,
  `userID` int NOT NULL,
  `agentID` int DEFAULT NULL,
  `chatTitle` varchar(100) NOT NULL,
  `defaultLangStyle` varchar(20) NOT NULL DEFAULT '',
  `isActive` varchar(1) NOT NULL DEFAULT 'Y',
  PRIMARY KEY (`chatID`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;


CREATE TABLE `chat_transcript` (
  `transcriptID` int NOT NULL AUTO_INCREMENT,
  `chatID` int NOT NULL,
  chatGPTRole varchar(50) NOT NULL,
  `sentBy` varchar(50) NOT NULL,
  `sentByID` int NOT NULL,
  `msg` text,
  `sentDate` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`transcriptID`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;



truncate table agents;

insert into agents (userID, agentName, agentTitle, agentDescription, agentImgPrefix,agentType, agentRole) 
values (-1
			,'Joker'
			,'A Comedian'
            ,'A bot that only responds with a joke'
            ,'joker-avatar'
            ,'bot'
            ,'bot');
            

insert into agent_prompts (agentID, promptTitle, prompt, promptType, promptStatus)
values (1, 'General','From now on all your answers will be in the form of joke or riddle','pre-prompt','Active');


