CREATE TABLE IF NOT EXISTS `madmin_accounts` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `username` varchar(200) CHARACTER SET utf8mb4 NOT NULL,
  `password` varchar(200) CHARACTER SET utf8mb4 DEFAULT NULL,
  `discord` varchar(200) CHARACTER SET utf8mb4 DEFAULT NULL,
  `avatar` varchar(200) CHARACTER SET utf8mb4 NOT NULL DEFAULT 'https://cdn.discordapp.com/icons/790686655430393868/a_3199ef6663eb0a46c022f8dc99584238?size=128',
  `rank` varchar(200) CHARACTER SET utf8mb4 NOT NULL DEFAULT 'Not Authorized',
  `ip` varchar(200) CHARACTER SET utf8mb4 DEFAULT NULL,
  `accountType` varchar(200) CHARACTER SET utf8mb4 NOT NULL,
  `darkMode` int(11) NOT NULL DEFAULT 0,
  `discord_token` varchar(200) CHARACTER SET utf8mb4 DEFAULT NULL,
  `syncedDarkMode` int(11) NOT NULL DEFAULT 0,
  `discord_avatar` varchar(500) NOT NULL DEFAULT '',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `madmin_bans` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(200) NOT NULL,
  `steam` varchar(200) NOT NULL,
  `license` varchar(200) NOT NULL,
  `discord` varchar(200) NOT NULL,
  `reason` varchar(300) NOT NULL,
  `endTime` bigint(20) NOT NULL,
  `bannedBy` varchar(200) NOT NULL,
  `bannedAt` varchar(200) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `identifiers` (`steam`)
) ENGINE=InnoDB AUTO_INCREMENT=35 DEFAULT CHARSET=utf8;


CREATE TABLE IF NOT EXISTS `madmin_blacklist` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(200) NOT NULL,
  `license` varchar(500) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `license` (`license`)
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `madmin_blips` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(200) NOT NULL,
  `coords` varchar(200) NOT NULL,
  `sprite` int(11) NOT NULL,
  `color` int(11) NOT NULL,
  `scale` varchar(200) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `coords` (`coords`)
) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=utf8;


CREATE TABLE IF NOT EXISTS `madmin_characters` (
  `name` varchar(500) NOT NULL,
  `identifier` varchar(250) NOT NULL,
  `license` varchar(250) NOT NULL,
  `discord` varchar(200) NOT NULL,
  `steam` varchar(200) NOT NULL,
  `discord_avatar` varchar(500) NOT NULL,
  `online_time` varchar(200) NOT NULL DEFAULT '0',
  PRIMARY KEY (`identifier`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `madmin_factions` (
  `faction` varchar(200) NOT NULL,
  `type` varchar(200) NOT NULL DEFAULT 'gangs',
  `image` varchar(500) NOT NULL DEFAULT 'img/DefaultFactionIcon.png',
  PRIMARY KEY (`faction`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `madmin_jaildata` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `identifier` varchar(500) NOT NULL,
  `jailTime` bigint(20) NOT NULL,
  `currentTime` bigint(20) NOT NULL,
  `reason` varchar(500) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `madmin_jobs` (
  `job` varchar(200) NOT NULL,
  `type` varchar(200) NOT NULL DEFAULT 'state',
  `image` varchar(200) NOT NULL DEFAULT 'img/DefaultJobIcon.png',
  PRIMARY KEY (`job`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `madmin_logs` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `type` varchar(200) NOT NULL,
  `author` varchar(200) NOT NULL,
  `message` longtext NOT NULL,
  `date` varchar(200) NOT NULL,
  `player_uid` varchar(200) NOT NULL,
  `count` bigint(20) NOT NULL DEFAULT 0,
  `cancelled` int(1) NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=748 DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `madmin_permissions` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(200) NOT NULL,
  `pattern` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL DEFAULT '{"FullPermission": false,"Dashboard":[false,false,false,false,false,false],"Players":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],"Accounts":[false,false,false],"LiveMap":[false,false],"Vehicles":[false,false,false,false,false,false],"Items":[false,false],"Jobs":[false,false,false,false,false],"Factions":[false,false,false,false,false],"Logs":[false],"LiveConsole":[false],"Resources":[false,false],"Admins":[false,false,false],"Management":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false]}' CHECK (json_valid(`pattern`)),
  `createdBy` varchar(200) NOT NULL DEFAULT 'System',
  `createdDate` varchar(200) NOT NULL DEFAULT date_format(curdate(),'%d.%m.%Y'),
  PRIMARY KEY (`id`),
  UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `madmin_registers` (
  `id` int(11) NOT NULL DEFAULT 0,
  `username` varchar(200) CHARACTER SET utf8mb4 NOT NULL,
  `password` varchar(200) CHARACTER SET utf8mb4 DEFAULT NULL,
  `discord` varchar(200) CHARACTER SET utf8mb4 DEFAULT NULL,
  `avatar` varchar(200) CHARACTER SET utf8mb4 NOT NULL DEFAULT 'https://cdn.discordapp.com/icons/790686655430393868/a_3199ef6663eb0a46c022f8dc99584238?size=128',
  `rank` varchar(200) CHARACTER SET utf8mb4 NOT NULL DEFAULT 'Not Authorized',
  `ip` varchar(200) CHARACTER SET utf8mb4 DEFAULT NULL,
  `accountType` varchar(200) CHARACTER SET utf8mb4 NOT NULL,
  `darkMode` int(11) NOT NULL DEFAULT 0,
  `discord_token` varchar(200) CHARACTER SET utf8mb4 DEFAULT NULL,
  `request` int(11) NOT NULL DEFAULT 1,
  `date` varchar(200) NOT NULL DEFAULT date_format(curdate(),'%d.%m.%Y'),
  `discord_avatar` varchar(500) NOT NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `madmin_vehicles` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `model` varchar(200) NOT NULL,
  `class` varchar(200) NOT NULL,
  `category` varchar(200) NOT NULL,
  `import` int(11) NOT NULL DEFAULT 0,
  `image` varchar(200) NOT NULL DEFAULT 'img/CarImage.png',
  PRIMARY KEY (`id`),
  UNIQUE KEY `model` (`model`)
) ENGINE=InnoDB AUTO_INCREMENT=554 DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `madmin_vips` (
  `id` int(11) NOT NULL DEFAULT 0,
  `uid` varchar(200) CHARACTER SET utf8mb4 NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;