Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update DB Structure #57

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 67 additions & 46 deletions src/main/resources/create.sql
Original file line number Diff line number Diff line change
@@ -1,51 +1,72 @@
# LagMonitor table
CREATE TABLE IF NOT EXISTS `{prefix}monitor` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`process_usage` float unsigned NOT NULL,
`os_usage` float unsigned NOT NULL,
`free_ram` mediumint(8) unsigned NOT NULL,
`free_ram_pct` float unsigned NOT NULL,
`os_free_ram` mediumint(8) unsigned NOT NULL,
`os_free_ram_pct` float unsigned NOT NULL,
`load_avg` float unsigned NOT NULL,
`updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

CREATE TABLE IF NOT EXISTS `{prefix}native` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`mc_read` smallint(5) unsigned DEFAULT NULL,
`mc_write` smallint(5) unsigned DEFAULT NULL,
`free_space` int(10) unsigned DEFAULT NULL,
`free_space_pct` float unsigned DEFAULT NULL,
`disk_read` smallint(5) unsigned DEFAULT NULL,
`disk_write` smallint(5) unsigned DEFAULT NULL,
`net_read` smallint(5) unsigned DEFAULT NULL,
`net_write` smallint(5) unsigned DEFAULT NULL,
`updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`native_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

CREATE TABLE IF NOT EXISTS `{prefix}tps` (
tps_id INTEGER UNSIGNED PRIMARY KEY AUTO_INCREMENT,
tps FLOAT UNSIGNED NOT NULL,
updated TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`tps` float unsigned NOT NULL,
`updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

CREATE TABLE IF NOT EXISTS `{prefix}monitor` (
monitor_id INTEGER UNSIGNED PRIMARY KEY AUTO_INCREMENT,
process_usage FLOAT UNSIGNED NOT NULL,
os_usage FLOAT UNSIGNED NOT NULL,
free_ram MEDIUMINT UNSIGNED NOT NULL,
free_ram_pct FLOAT UNSIGNED NOT NULL,
os_free_ram MEDIUMINT UNSIGNED NOT NULL,
os_free_ram_pct FLOAT UNSIGNED NOT NULL,
load_avg FLOAT UNSIGNED NOT NULL,
updated TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE IF NOT EXISTS `{prefix}player` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`uuid` char(40) NOT NULL,
`name` varchar(16) NOT NULL,
`updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `uuid` (`uuid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

CREATE TABLE IF NOT EXISTS `{prefix}worlds` (
world_id INTEGER UNSIGNED PRIMARY KEY AUTO_INCREMENT,
monitor_id INTEGER UNSIGNED NOT NULL,
world_name VARCHAR(255) NOT NULL,
chunks_loaded SMALLINT UNSIGNED NOT NULL,
tile_entities SMALLINT UNSIGNED NOT NULL,
world_size MEDIUMINT UNSIGNED NOT NULL,
entities INT UNSIGNED NOT NULL,
FOREIGN KEY (monitor_id) REFERENCES `{prefix}monitor` (monitor_id)
);
CREATE TABLE IF NOT EXISTS `{prefix}world` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

CREATE TABLE IF NOT EXISTS `{prefix}players` (
world_id INTEGER UNSIGNED,
uuid CHAR(40) NOT NULL,
NAME VARCHAR(16) NOT NULL,
ping SMALLINT UNSIGNED NOT NULL,
PRIMARY KEY (world_id, uuid),
FOREIGN KEY (world_id) REFERENCES `{prefix}worlds` (world_id)
);
CREATE TABLE IF NOT EXISTS `{prefix}player_data` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`player` int(10) unsigned NOT NULL,
`world` int(10) unsigned NOT NULL,
`ping` int(10) unsigned NOT NULL DEFAULT '0',
`updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
FOREIGN KEY (`player`) REFERENCES `{prefix}player` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY (`world`) REFERENCES `{prefix}world` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

CREATE TABLE IF NOT EXISTS `{prefix}native` (
native_id INTEGER UNSIGNED PRIMARY KEY AUTO_INCREMENT,
mc_read SMALLINT UNSIGNED,
mc_write SMALLINT UNSIGNED,
free_space INT UNSIGNED,
free_space_pct FLOAT UNSIGNED,
disk_read SMALLINT UNSIGNED,
disk_write SMALLINT UNSIGNED,
net_read SMALLINT UNSIGNED,
net_write SMALLINT UNSIGNED,
updated TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE IF NOT EXISTS `{prefix}world_data` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`world` int(10) unsigned NOT NULL,
`chunks_loaded` smallint(5) unsigned NOT NULL,
`tile_entities` smallint(5) unsigned NOT NULL,
`world_size` mediumint(8) unsigned NOT NULL,
`entities` int(10) unsigned NOT NULL,
`updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
FOREIGN KEY (`world`) REFERENCES `{prefix}world` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;