UltimateStacker/UltimateStacker/src/main/java/com.craftaro.ultimatestacker/database/migrations/_3_BlockStacks.java

36 lines
1.2 KiB
Java
Raw Normal View History

2023-05-25 19:20:03 +02:00
package com.craftaro.ultimatestacker.database.migrations;
2020-08-25 01:01:11 +02:00
2023-05-30 11:21:46 +02:00
import com.craftaro.ultimatestacker.UltimateStacker;
import com.craftaro.core.database.DataMigration;
import com.craftaro.core.database.DatabaseConnector;
import com.craftaro.core.database.MySQLConnector;
2020-08-25 01:01:11 +02:00
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
public class _3_BlockStacks extends DataMigration {
public _3_BlockStacks() {
super(3);
}
@Override
public void migrate(DatabaseConnector connector, String tablePrefix) throws SQLException {
String autoIncrement = connector instanceof MySQLConnector ? " AUTO_INCREMENT" : "";
2020-08-25 01:01:11 +02:00
// Create blocks table
try (Statement statement = connector.getConnection().createStatement()) {
statement.execute("CREATE TABLE IF NOT EXISTS " + tablePrefix + "blocks (" +
2020-08-25 01:01:11 +02:00
"id INTEGER PRIMARY KEY" + autoIncrement + ", " +
"amount INTEGER NOT NULL," +
2020-10-19 20:26:18 +02:00
"material TEXT NOT NULL," +
2020-08-25 01:01:11 +02:00
"world TEXT NOT NULL, " +
"x DOUBLE NOT NULL, " +
"y DOUBLE NOT NULL, " +
"z DOUBLE NOT NULL " +
")");
}
}
}