mirror of
https://github.com/songoda/UltimateStacker.git
synced 2025-02-05 05:51:22 +01:00
Update migrations
This commit is contained in:
parent
e5ccac8cdf
commit
ec09a56a02
@ -4,6 +4,7 @@ import com.craftaro.core.database.DataMigration;
|
||||
import com.craftaro.core.database.DatabaseConnector;
|
||||
import com.craftaro.core.database.MySQLConnector;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
|
||||
@ -14,13 +15,12 @@ public class _1_InitialMigration extends DataMigration {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void migrate(DatabaseConnector connector, String tablePrefix) throws SQLException {
|
||||
String autoIncrement = connector instanceof MySQLConnector ? " AUTO_INCREMENT" : "";
|
||||
public void migrate(Connection connection, String tablePrefix) throws SQLException {
|
||||
|
||||
// Create spawners table
|
||||
try (Statement statement = connector.getConnection().createStatement()) {
|
||||
try (Statement statement = connection.createStatement()) {
|
||||
statement.execute("CREATE TABLE IF NOT EXISTS " + tablePrefix + "spawners (" +
|
||||
"id INTEGER PRIMARY KEY" + autoIncrement + ", " +
|
||||
"id INTEGER PRIMARY KEY AUTO_INCREMENT, " +
|
||||
"amount INTEGER NOT NULL," +
|
||||
"world TEXT NOT NULL, " +
|
||||
"x DOUBLE NOT NULL, " +
|
||||
|
@ -4,6 +4,7 @@ import com.craftaro.core.database.DataMigration;
|
||||
import com.craftaro.core.database.DatabaseConnector;
|
||||
import com.craftaro.core.database.MySQLConnector;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
|
||||
@ -14,13 +15,11 @@ public class _2_EntityStacks extends DataMigration {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void migrate(DatabaseConnector connector, String tablePrefix) throws SQLException {
|
||||
String autoIncrement = connector instanceof MySQLConnector ? " AUTO_INCREMENT" : "";
|
||||
|
||||
public void migrate(Connection connection, String tablePrefix) throws SQLException {
|
||||
// Create host entities table
|
||||
try (Statement statement = connector.getConnection().createStatement()) {
|
||||
try (Statement statement = connection.createStatement()) {
|
||||
statement.execute("CREATE TABLE IF NOT EXISTS " + tablePrefix + "host_entities (" +
|
||||
"id INTEGER PRIMARY KEY" + autoIncrement + ", " +
|
||||
"id INTEGER PRIMARY KEY AUTO_INCREMENT, " +
|
||||
"uuid VARCHAR(36) NOT NULL," +
|
||||
"create_duplicates INTEGER NOT NULL DEFAULT 0" +
|
||||
")");
|
||||
|
@ -4,6 +4,7 @@ import com.craftaro.core.database.DataMigration;
|
||||
import com.craftaro.core.database.DatabaseConnector;
|
||||
import com.craftaro.core.database.MySQLConnector;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
|
||||
@ -14,13 +15,12 @@ public class _3_BlockStacks extends DataMigration {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void migrate(DatabaseConnector connector, String tablePrefix) throws SQLException {
|
||||
String autoIncrement = connector instanceof MySQLConnector ? " AUTO_INCREMENT" : "";
|
||||
public void migrate(Connection connection, String tablePrefix) throws SQLException {
|
||||
|
||||
// Create blocks table
|
||||
try (Statement statement = connector.getConnection().createStatement()) {
|
||||
try (Statement statement = connection.createStatement()) {
|
||||
statement.execute("CREATE TABLE IF NOT EXISTS " + tablePrefix + "blocks (" +
|
||||
"id INTEGER PRIMARY KEY" + autoIncrement + ", " +
|
||||
"id INTEGER PRIMARY KEY AUTO_INCREMENT, " +
|
||||
"amount INTEGER NOT NULL," +
|
||||
"material TEXT NOT NULL," +
|
||||
"world TEXT NOT NULL, " +
|
||||
|
@ -3,6 +3,7 @@ package com.craftaro.ultimatestacker.database.migrations;
|
||||
import com.craftaro.core.database.DataMigration;
|
||||
import com.craftaro.core.database.DatabaseConnector;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
|
||||
@ -13,8 +14,8 @@ public class _6_RemoveStackedEntityTable extends DataMigration {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void migrate(DatabaseConnector connector, String tablePrefix) {
|
||||
try (Statement statement = connector.getConnection().createStatement()) {
|
||||
public void migrate(Connection connection, String tablePrefix) {
|
||||
try (Statement statement = connection.createStatement()) {
|
||||
statement.execute("DROP TABLE IF EXISTS " + tablePrefix + "stacked_entities");
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
|
Loading…
Reference in New Issue
Block a user