Skip to content

Commit

Permalink
feat: add support for PostgreSQL data storage (#616)
Browse files Browse the repository at this point in the history
Signed-off-by: PseudoResonance <kaio11604@gmail.com>
  • Loading branch information
PseudoResonance committed Apr 23, 2024
1 parent 9cc21e2 commit 7ad9104
Show file tree
Hide file tree
Showing 11 changed files with 1,386 additions and 17 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ ext {
set 'sqlite_driver_version', sqlite_driver_version.toString()
set 'mysql_driver_version', mysql_driver_version.toString()
set 'mariadb_driver_version', mariadb_driver_version.toString()
set 'postgresql_driver_version', postgresql_driver_version.toString()
}

publishing {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@
import net.william278.huskhomes.config.Server;
import net.william278.huskhomes.config.Settings;
import net.william278.huskhomes.config.Spawn;
import net.william278.huskhomes.database.Database;
import net.william278.huskhomes.database.H2Database;
import net.william278.huskhomes.database.MySqlDatabase;
import net.william278.huskhomes.database.SqLiteDatabase;
import net.william278.huskhomes.database.*;
import net.william278.huskhomes.event.BukkitEventDispatcher;
import net.william278.huskhomes.hook.Hook;
import net.william278.huskhomes.hook.PlaceholderAPIHook;
Expand Down Expand Up @@ -138,6 +135,7 @@ public void onEnable() {
case MYSQL, MARIADB -> new MySqlDatabase(this);
case SQLITE -> new SqLiteDatabase(this);
case H2 -> new H2Database(this);
case POSTGRESQL -> new PostgreSqlDatabase(this);
};

database.initialize();
Expand Down
1 change: 1 addition & 0 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ dependencies {
compileOnly "com.mysql:mysql-connector-j:${mysql_driver_version}"
compileOnly "org.mariadb.jdbc:mariadb-java-client:${mariadb_driver_version}"
compileOnly "com.h2database:h2:${h2_driver_version}"
compileOnly "org.postgresql:postgresql:${postgresql_driver_version}"

compileOnly 'org.jetbrains:annotations:24.1.0'
compileOnly 'com.google.guava:guava:33.1.0-jre'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ public final class Settings {
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public static class DatabaseSettings {

@Comment("Type of database to use (SQLITE, H2, MYSQL, or MARIADB)")
@Comment("Type of database to use (SQLITE, H2, MYSQL, MARIADB, or POSTGRESQL)")
private Database.Type type = Database.Type.SQLITE;

@Comment("Specify credentials here if you are using MYSQL or MARIADB")
@Comment("Specify credentials here if you are using MYSQL, MARIADB, or POSTGRESQL")
private DatabaseCredentials credentials = new DatabaseCredentials();

@Getter
Expand All @@ -89,7 +89,7 @@ public static class DatabaseCredentials {
"useUnicode=true", "characterEncoding=UTF-8");
}

@Comment({"MYSQL / MARIADB database Hikari connection pool properties",
@Comment({"MYSQL / MARIADB / POSTGRESQL database Hikari connection pool properties",
"Don't modify this unless you know what you're doing!"})
private PoolOptions poolOptions = new PoolOptions();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,8 @@ public enum Type {
MYSQL("MySQL", "mysql"),
MARIADB("MariaDB", "mariadb"),
SQLITE("SQLite", "sqlite"),
H2("H2", "h2");
H2("H2", "h2"),
POSTGRESQL("PostgreSQL", "postgresql");

private final String displayName;
private final String protocol;
Expand Down
Loading

0 comments on commit 7ad9104

Please sign in to comment.