mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-02 14:38:52 +00:00
Add H2 database support, use indexes to optimize queries, add maria-specific schema, bump adventure-fabric (#465)
* Add support for H2, bundle Maria driver, bump fabric adventure * Bundle and download H2 drivers * Fixup H2 schema, add indexes to DBs, add maria-specific schema * docs: Add database type documentation * Check plugin isn't disabled before task schedule, close #463 * Bump Annotaml to 2.0.4 * docs: Mention Maria in README and Setup
This commit is contained in:
1 parent
8d2424a7ef
commit
beed438c16
28 files changed
+1443
-50
No files matched your search
@@ -0,0 +1,94 @@
|
||||
/* Create the positions table if it does not exist */
|
||||
CREATE TABLE IF NOT EXISTS `%positions_table%`
|
||||
(
|
||||
`id` INT NOT NULL AUTO_INCREMENT,
|
||||
`x` DOUBLE NOT NULL,
|
||||
`y` DOUBLE NOT NULL,
|
||||
`z` DOUBLE NOT NULL,
|
||||
`yaw` REAL NOT NULL,
|
||||
`pitch` REAL NOT NULL,
|
||||
`world_name` VARCHAR(255) NOT NULL,
|
||||
`world_uuid` UUID NOT NULL,
|
||||
`server_name` VARCHAR(255) NOT NULL,
|
||||
|
||||
PRIMARY KEY (`id`)
|
||||
);
|
||||
|
||||
/* Create the players table if it does not exist */
|
||||
CREATE TABLE IF NOT EXISTS `%players_table%`
|
||||
(
|
||||
`uuid` UUID NOT NULL PRIMARY KEY,
|
||||
`username` VARCHAR(16) NOT NULL,
|
||||
`last_position` INT NULL,
|
||||
`offline_position` INT NULL,
|
||||
`respawn_position` INT NULL,
|
||||
`home_slots` INT NOT NULL DEFAULT 0,
|
||||
`ignoring_requests` BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
|
||||
FOREIGN KEY (`last_position`) REFERENCES `%positions_table%` (`id`) ON DELETE SET NULL ON UPDATE NO ACTION,
|
||||
FOREIGN KEY (`offline_position`) REFERENCES `%positions_table%` (`id`) ON DELETE SET NULL ON UPDATE NO ACTION,
|
||||
FOREIGN KEY (`respawn_position`) REFERENCES `%positions_table%` (`id`) ON DELETE SET NULL ON UPDATE NO ACTION
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS `%players_table%_username` ON `%players_table%` (`username`);
|
||||
|
||||
/* Create the cooldowns table if it does not exist */
|
||||
CREATE TABLE IF NOT EXISTS `%cooldowns_table%`
|
||||
(
|
||||
`id` INT NOT NULL AUTO_INCREMENT,
|
||||
`player_uuid` UUID NOT NULL,
|
||||
`type` VARCHAR(255) NOT NULL,
|
||||
`start_timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`end_timestamp` TIMESTAMP NOT NULL,
|
||||
|
||||
PRIMARY KEY (`id`),
|
||||
FOREIGN KEY (`player_uuid`) REFERENCES `%players_table%` (`uuid`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS `%cooldowns_table%_player_uuid` ON `%cooldowns_table%` (`player_uuid`);
|
||||
|
||||
/* Create the current cross-server teleports table if it does not exist */
|
||||
CREATE TABLE IF NOT EXISTS `%teleports_table%`
|
||||
(
|
||||
`player_uuid` UUID NOT NULL PRIMARY KEY,
|
||||
`destination_id` INT NOT NULL,
|
||||
`type` INT NOT NULL DEFAULT 0,
|
||||
|
||||
FOREIGN KEY (`player_uuid`) REFERENCES `%players_table%` (`uuid`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
FOREIGN KEY (`destination_id`) REFERENCES `%positions_table%` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION
|
||||
);
|
||||
|
||||
/* Create the saved positions table if it does not exist */
|
||||
CREATE TABLE IF NOT EXISTS `%saved_positions_table%`
|
||||
(
|
||||
`id` INT NOT NULL AUTO_INCREMENT,
|
||||
`position_id` INT NOT NULL,
|
||||
`name` VARCHAR(64) NOT NULL,
|
||||
`description` VARCHAR(255) NOT NULL,
|
||||
`tags` CLOB NULL,
|
||||
`timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
PRIMARY KEY (`id`),
|
||||
FOREIGN KEY (`position_id`) REFERENCES `%positions_table%` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS `%saved_positions_table%_name` ON `%saved_positions_table%` (`name`);
|
||||
|
||||
/* Create the homes table if it does not exist */
|
||||
CREATE TABLE IF NOT EXISTS `%homes_table%`
|
||||
(
|
||||
`uuid` UUID NOT NULL PRIMARY KEY,
|
||||
`saved_position_id` INT NOT NULL,
|
||||
`owner_uuid` UUID NOT NULL,
|
||||
`public` BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
|
||||
FOREIGN KEY (`owner_uuid`) REFERENCES `%players_table%` (`uuid`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
FOREIGN KEY (`saved_position_id`) REFERENCES `%saved_positions_table%` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS `%homes_table%_owner_uuid` ON `%homes_table%` (`owner_uuid`);
|
||||
|
||||
/* Create the warps table if it does not exist */
|
||||
CREATE TABLE IF NOT EXISTS `%warps_table%`
|
||||
(
|
||||
`uuid` UUID NOT NULL PRIMARY KEY,
|
||||
`saved_position_id` INT NOT NULL,
|
||||
|
||||
FOREIGN KEY (`saved_position_id`) REFERENCES `%saved_positions_table%` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION
|
||||
);
|
||||
@@ -0,0 +1,118 @@
|
||||
-- Set the storage engine
|
||||
SET DEFAULT_STORAGE_ENGINE = InnoDB;
|
||||
|
||||
-- Enable foreign key constraints
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
|
||||
-- Create the positions table if it does not exist
|
||||
CREATE TABLE IF NOT EXISTS `%positions_table%`
|
||||
(
|
||||
`id` INTEGER NOT NULL AUTO_INCREMENT,
|
||||
`x` DOUBLE NOT NULL,
|
||||
`y` DOUBLE NOT NULL,
|
||||
`z` DOUBLE NOT NULL,
|
||||
`yaw` FLOAT NOT NULL,
|
||||
`pitch` FLOAT NOT NULL,
|
||||
`world_name` VARCHAR(255) NOT NULL,
|
||||
`world_uuid` CHAR(36) NOT NULL,
|
||||
`server_name` VARCHAR(255) NOT NULL,
|
||||
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8mb4
|
||||
COLLATE = utf8mb4_unicode_ci;
|
||||
|
||||
-- Create the players table if it does not exist
|
||||
CREATE TABLE IF NOT EXISTS `%players_table%`
|
||||
(
|
||||
`uuid` CHAR(36) NOT NULL,
|
||||
`username` VARCHAR(16) NOT NULL,
|
||||
`last_position` INTEGER DEFAULT NULL,
|
||||
`offline_position` INTEGER DEFAULT NULL,
|
||||
`respawn_position` INTEGER DEFAULT NULL,
|
||||
`home_slots` INTEGER NOT NULL DEFAULT 0,
|
||||
`ignoring_requests` BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
|
||||
PRIMARY KEY (`uuid`),
|
||||
FOREIGN KEY (`last_position`) REFERENCES `%positions_table%` (`id`) ON DELETE SET NULL ON UPDATE NO ACTION,
|
||||
FOREIGN KEY (`offline_position`) REFERENCES `%positions_table%` (`id`) ON DELETE SET NULL ON UPDATE NO ACTION,
|
||||
FOREIGN KEY (`respawn_position`) REFERENCES `%positions_table%` (`id`) ON DELETE SET NULL ON UPDATE NO ACTION
|
||||
) ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8mb4
|
||||
COLLATE = utf8mb4_unicode_ci;
|
||||
CREATE INDEX IF NOT EXISTS `%players_table%_username` ON `%players_table%` (`username`);
|
||||
|
||||
-- Create the cooldowns table if it does not exist
|
||||
CREATE TABLE IF NOT EXISTS `%cooldowns_table%`
|
||||
(
|
||||
`id` INTEGER NOT NULL AUTO_INCREMENT,
|
||||
`player_uuid` CHAR(36) NOT NULL,
|
||||
`type` VARCHAR(255) NOT NULL,
|
||||
`start_timestamp` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`end_timestamp` DATETIME NOT NULL,
|
||||
|
||||
PRIMARY KEY (`id`),
|
||||
FOREIGN KEY (`player_uuid`) REFERENCES `%players_table%` (`uuid`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8mb4
|
||||
COLLATE = utf8mb4_unicode_ci;
|
||||
CREATE INDEX IF NOT EXISTS `%cooldowns_table%_player_uuid` ON `%cooldowns_table%` (`player_uuid`);
|
||||
|
||||
-- Create the current cross-server teleports table if it does not exist
|
||||
CREATE TABLE IF NOT EXISTS `%teleports_table%`
|
||||
(
|
||||
`player_uuid` CHAR(36) NOT NULL,
|
||||
`destination_id` INTEGER NOT NULL,
|
||||
`type` INTEGER NOT NULL DEFAULT 0,
|
||||
|
||||
PRIMARY KEY (`player_uuid`),
|
||||
FOREIGN KEY (`player_uuid`) REFERENCES `%players_table%` (`uuid`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
FOREIGN KEY (`destination_id`) REFERENCES `%positions_table%` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION
|
||||
) ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8mb4
|
||||
COLLATE = utf8mb4_unicode_ci;
|
||||
|
||||
-- Create the saved positions table if it does not exist
|
||||
CREATE TABLE IF NOT EXISTS `%saved_positions_table%`
|
||||
(
|
||||
`id` INTEGER NOT NULL AUTO_INCREMENT,
|
||||
`position_id` INTEGER NOT NULL,
|
||||
`name` VARCHAR(64) NOT NULL,
|
||||
`description` VARCHAR(255) NOT NULL,
|
||||
`tags` MEDIUMTEXT DEFAULT NULL,
|
||||
`timestamp` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
PRIMARY KEY (`id`),
|
||||
FOREIGN KEY (`position_id`) REFERENCES `%positions_table%` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION
|
||||
) ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8mb4
|
||||
COLLATE = utf8mb4_unicode_ci;
|
||||
CREATE INDEX IF NOT EXISTS `%saved_positions_table%_name` ON `%saved_positions_table%` (`name`);
|
||||
|
||||
-- Create the homes table if it does not exist
|
||||
CREATE TABLE IF NOT EXISTS `%homes_table%`
|
||||
(
|
||||
`uuid` CHAR(36) NOT NULL,
|
||||
`saved_position_id` INTEGER NOT NULL,
|
||||
`owner_uuid` CHAR(36) NOT NULL,
|
||||
`public` BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
|
||||
PRIMARY KEY (`uuid`),
|
||||
FOREIGN KEY (`owner_uuid`) REFERENCES `%players_table%` (`uuid`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
FOREIGN KEY (`saved_position_id`) REFERENCES `%saved_positions_table%` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION
|
||||
) ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8mb4
|
||||
COLLATE = utf8mb4_unicode_ci;
|
||||
CREATE INDEX IF NOT EXISTS `%homes_table%_owner_uuid` ON `%homes_table%` (`owner_uuid`);
|
||||
|
||||
-- Create the warps table if it does not exist
|
||||
CREATE TABLE IF NOT EXISTS `%warps_table%`
|
||||
(
|
||||
`uuid` CHAR(36) NOT NULL,
|
||||
`saved_position_id` INTEGER NOT NULL,
|
||||
|
||||
PRIMARY KEY (`uuid`),
|
||||
FOREIGN KEY (`saved_position_id`) REFERENCES `%saved_positions_table%` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION
|
||||
) ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8mb4
|
||||
COLLATE = utf8mb4_unicode_ci;
|
||||
@@ -30,6 +30,7 @@ CREATE TABLE IF NOT EXISTS `%players_table%`
|
||||
FOREIGN KEY (`offline_position`) REFERENCES `%positions_table%` (`id`) ON DELETE SET NULL ON UPDATE NO ACTION,
|
||||
FOREIGN KEY (`respawn_position`) REFERENCES `%positions_table%` (`id`) ON DELETE SET NULL ON UPDATE NO ACTION
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS `%players_table%_username` ON `%players_table%` (`username`);
|
||||
|
||||
/* Create the cooldowns table if it does not exist */
|
||||
CREATE TABLE IF NOT EXISTS `%cooldowns_table%`
|
||||
@@ -43,6 +44,7 @@ CREATE TABLE IF NOT EXISTS `%cooldowns_table%`
|
||||
PRIMARY KEY (`id`),
|
||||
FOREIGN KEY (`player_uuid`) REFERENCES `%players_table%` (`uuid`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS `%cooldowns_table%_player_uuid` ON `%cooldowns_table%` (`player_uuid`);
|
||||
|
||||
/* Create the current cross-server teleports table if it does not exist */
|
||||
CREATE TABLE IF NOT EXISTS `%teleports_table%`
|
||||
@@ -69,6 +71,7 @@ CREATE TABLE IF NOT EXISTS `%saved_positions_table%`
|
||||
PRIMARY KEY (`id`),
|
||||
FOREIGN KEY (`position_id`) REFERENCES `%positions_table%` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS `%saved_positions_table%_name` ON `%saved_positions_table%` (`name`);
|
||||
|
||||
/* Create the homes table if it does not exist */
|
||||
CREATE TABLE IF NOT EXISTS `%homes_table%`
|
||||
@@ -82,6 +85,7 @@ CREATE TABLE IF NOT EXISTS `%homes_table%`
|
||||
FOREIGN KEY (`owner_uuid`) REFERENCES `%players_table%` (`uuid`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
FOREIGN KEY (`saved_position_id`) REFERENCES `%saved_positions_table%` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS `%homes_table%_owner_uuid` ON `%homes_table%` (`owner_uuid`);
|
||||
|
||||
/* Create the warps table if it does not exist */
|
||||
CREATE TABLE IF NOT EXISTS `%warps_table%`
|
||||
|
||||
Reference in new issue
Block a user