Removed create table on startup to follow DB policies

This commit is contained in:
xGamingDudex 2016-05-31 21:19:34 +02:00
parent 4fc3c491f8
commit 22bf3bfd03

View File

@ -4,7 +4,6 @@ import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
@ -14,35 +13,24 @@ import mineplex.serverdata.database.DBPool;
/**
* Repository for Mavericks-MasterBuilders SQL game data
* -
* Table to back this repository may be created with
* CREATE TABLE IF NOT EXISTS mavericksMasterBuildersBuilds (
accountId INT NOT NULL,
BuildTheme VARCHAR(255) NOT NULL,
Points DOUBLE NOT NULL,
Place INT NOT NULL,
Date BIGINT NOT NULL,
Schematic BLOB,
PRIMARY KEY (accountId,Date),
INDEX acc_ind (accountId),
FOREIGN KEY (accountId) REFERENCES accounts(id) ON DELETE NO ACTION ON UPDATE NO ACTION
);
*/
public class MavericksRepository
{
private static final String TABLE = "MavericksMasterBuildersBuilds";
public MavericksRepository()
{
// Create a table to back this repository
try (Connection conn = DBPool.getAccount().getConnection())
{
Statement stmt = conn.createStatement();
stmt.executeUpdate("CREATE TABLE IF NOT EXISTS " + TABLE + "("
+ "accountId INT NOT NULL,"
+ "BuildTheme VARCHAR(255) NOT NULL,"
+ "Points DOUBLE NOT NULL,"
+ "Place INT NOT NULL,"
+ "Date BIGINT NOT NULL,"
+ "Schematic BLOB,"
+ "PRIMARY KEY (accountId,Date),"
+ "INDEX acc_ind (accountId),"
+ "FOREIGN KEY (accountId) REFERENCES accounts(id) ON DELETE NO ACTION ON UPDATE NO ACTION"
+ ")");
}
catch (SQLException e)
{
e.printStackTrace();
}
}
private static final String TABLE = "mavericksMasterBuildersBuilds";
public CompletableFuture<Boolean> add(MavericksBuildWrapper data)
{