﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Kitsunebot.Database.Models
{
    public class ChatMessage : IModel
    {
        public Guid ID { get; set; }
        public Guid UserID { get; set; }
        public Guid? ChannelID { get; set; }
        public string Message { get; set; }
        public DateTime Time { get; set; }
        public string GetTableName()
        {
            return "chatmessages";
        }

        public string GetTableDefinition(DatabaseType dbtype)
        {
            return @"CREATE TABLE IF NOT EXISTS `chatmessages` (
  `ID` char(36) COLLATE utf8_bin NOT NULL,
  `UserID` char(36) COLLATE utf8_bin NOT NULL,
  `ChannelID` char(36) COLLATE utf8_bin DEFAULT NULL,
  `Message` text CHARACTER SET utf8 NOT NULL,
  `Time` datetime NOT NULL,
  PRIMARY KEY (`ID`),
  KEY `UserID` (`UserID`,`ChannelID`),
  FOREIGN KEY (`ChannelID`) REFERENCES `channels`(`ID`),
  FOREIGN KEY (`UserID`) REFERENCES `users`(`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;";
        }

        public int GetOrder()
        {
            return 1;
        }
    }
}
