Skip to content

Commit

Permalink
💎 Fix db table creation error, closes #47
Browse files Browse the repository at this point in the history
Took 11 minutes
  • Loading branch information
kiranhart committed Oct 3, 2024
1 parent 1efe0b8 commit 96c9dbc
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,18 @@ public void migrate(Connection connection, String tablePrefix) throws SQLExcepti

try (Statement statement = connection.createStatement()) {

statement.execute("CREATE TABLE " + tablePrefix + "players (" +
statement.execute("CREATE TABLE IF NOT EXISTS " + tablePrefix + "players (" +
"uuid VARCHAR(36) PRIMARY KEY, " +
"favourites TEXT" +
")");

statement.execute("CREATE TABLE " + tablePrefix + "categories (" +
statement.execute("CREATE TABLE IF NOT EXISTS " + tablePrefix + "categories (" +
"id VARCHAR(64) PRIMARY KEY, " +
"name VARCHAR(72) NOT NULL, " +
"skulls TEXT NULL" +
")");

statement.execute("CREATE TABLE " + tablePrefix + "skull (" +
statement.execute("CREATE TABLE IF NOT EXISTS " + tablePrefix + "skull (" +
"id INTEGER PRIMARY KEY, " +
"name VARCHAR(64) NOT NULL, " +
"category VARCHAR(16) NOT NULL, " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public _2_PlacedSkullsMigration() {
public void migrate(Connection connection, String tablePrefix) throws SQLException {

try (Statement statement = connection.createStatement()) {
statement.execute("CREATE TABLE " + tablePrefix + "placed_skull (" +
statement.execute("CREATE TABLE IF NOT EXISTS " + tablePrefix + "placed_skull (" +
"id VARCHAR(36) NOT NULL, " +
"skull_id INTEGER NOT NULL," +
"location VARCHAR(128) NOT NULL" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public _3_HistoryRemovalMigration() {
public void migrate(Connection connection, String tablePrefix) throws SQLException {

try (Statement statement = connection.createStatement()) {
statement.execute("DROP TABLE " + tablePrefix + "history");
statement.execute("DROP TABLE IF EXISTS " + tablePrefix + "history");
}
}
}

0 comments on commit 96c9dbc

Please sign in to comment.