新建了部分数据库表

This commit is contained in:
zhangyuheng 2024-05-13 01:43:34 +08:00
parent 87d0436821
commit e051167757
2 changed files with 68 additions and 0 deletions

View File

@ -23,6 +23,7 @@ public final class EssentialsD extends JavaPlugin {
instance = this;
config = new ConfigManager(instance);
dbConnection = DatabaseManager.createConnection();
DatabaseManager.migrate();
scheduler = new Scheduler(this);
tpManager = new TeleportManager();

View File

@ -89,5 +89,72 @@ public class DatabaseManager {
public static void migrate() {
String sql = "";
// player name
sql = "CREATE TABLE IF NOT EXISTS player_name (" +
" uuid VARCHAR(36) NOT NULL UNIQUE PRIMARY KEY," +
" last_known_name TEXT NOT NULL" +
");";
query(sql);
// login record
sql = "CREATE TABLE IF NOT EXISTS login_record (" +
" id SERIAL PRIMARY KEY," +
" uuid VARCHAR(36) NOT NULL," +
" ip VARCHAR(15) NOT NULL," +
" name TEXT NOT NULL," +
" login_time TIMESTAMP NOT NULL," +
" logout_location TEXT," +
" logout_time TIMESTAMP" +
");";
query(sql);
// name record
sql = "CREATE TABLE IF NOT EXISTS name_record (" +
" id SERIAL PRIMARY KEY," +
" uuid VARCHAR(36) NOT NULL," +
" name TEXT NOT NULL," +
" time TIMESTAMP NOT NULL" +
");";
query(sql);
// tp record
sql = "CREATE TABLE IF NOT EXISTS tp_record (" +
" id SERIAL PRIMARY KEY," +
" initiator_uuid VARCHAR(36) NOT NULL," +
" from_location TEXT NOT NULL," +
" to_location TEXT NOT NULL," +
" type TEXT NOT NULL," +
" success BOOLEAN NOT NULL," +
" time TIMESTAMP NOT NULL" +
");";
query(sql);
// message record
sql = "CREATE TABLE IF NOT EXISTS message_record (" +
" id SERIAL PRIMARY KEY," +
" sender_uuid VARCHAR(36) NOT NULL," +
" message TEXT NOT NULL," +
" time TIMESTAMP NOT NULL" +
");";
query(sql);
// command record
sql = "CREATE TABLE IF NOT EXISTS command_record (" +
" id SERIAL PRIMARY KEY," +
" executor_uuid VARCHAR(36) NOT NULL," +
" command TEXT NOT NULL," +
" time TIMESTAMP NOT NULL" +
");";
query(sql);
// home info
sql = "CREATE TABLE IF NOT EXISTS home_info (" +
" id SERIAL PRIMARY KEY," +
" uuid VARCHAR(36) NOT NULL," +
" home_name TEXT NOT NULL," +
" location TEXT NOT NULL" +
");";
query(sql);
}
}