Skip to content

Commit

Permalink
refactor(sql): unique index on licenses
Browse files Browse the repository at this point in the history
Also add colour to ox_groups.
  • Loading branch information
thelindat committed Jan 2, 2023
1 parent 7908479 commit eef80e5
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions database.sql
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,27 @@ CREATE TABLE IF NOT EXISTS `ox_groups` (
`name` VARCHAR(20) NOT NULL,
`label` VARCHAR(50) NOT NULL,
`grades` LONGTEXT NOT NULL,
`hasAccount` BIT NOT NULL DEFAULT 0,
`adminGrade` TINYINT UNSIGNED NOT NULL DEFAULT JSON_LENGTH(grades),
`hasAccount` BIT(1) NOT NULL DEFAULT b '0',
`adminGrade` TINYINT UNSIGNED NOT NULL DEFAULT json_length(`grades`),
`colour` TINYINT UNSIGNED DEFAULT NULL,
PRIMARY KEY (`name`) USING BTREE
);

INSERT INTO `ox_groups` (`name`, `label`, `grades`)
INSERT INTO `ox_groups` (
`name`,
`label`,
`grades`,
`hasAccount`,
`adminGrade`,
`colour`
)
VALUES (
'police',
'Los Santos Police Department',
'["Cadet", "Officer", "Sergeant", "Captain", "Commander", "Chief"]'
'["Cadet", "Officer", "Sergeant", "Captain", "Commander", "Chief"]',
b '0',
6,
NULL
);

CREATE TABLE IF NOT EXISTS `character_groups` (
Expand All @@ -93,7 +104,7 @@ CREATE TABLE IF NOT EXISTS `character_groups` (
CREATE TABLE IF NOT EXISTS `ox_inventory` (
`owner` VARCHAR(60) DEFAULT NULL,
`name` VARCHAR(60) NOT NULL,
`data` longtext DEFAULT NULL,
`data` LONGTEXT DEFAULT NULL,
`lastupdated` timestamp NULL DEFAULT CURRENT_TIMESTAMP() ON UPDATE CURRENT_TIMESTAMP(),
UNIQUE KEY `owner` (`owner`, `name`)
);
Expand Down Expand Up @@ -140,7 +151,8 @@ CREATE TABLE IF NOT EXISTS `character_licenses` (

CREATE TABLE IF NOT EXISTS `ox_licenses` (
`name` VARCHAR(20) NOT NULL,
`label` VARCHAR(50) NOT NULL
`label` VARCHAR(50) NOT NULL,
UNIQUE INDEX `name` (`name`) USING BTREE
);

INSERT INTO `ox_licenses` (`name`, `label`)
Expand Down

0 comments on commit eef80e5

Please sign in to comment.