1
0
mirror of https://github.com/Rogiel/l2jserver2 synced 2025-12-05 23:22:47 +00:00

Implements better schema management

This commit is contained in:
2011-12-26 01:08:27 -02:00
parent 1a4a4b0fcf
commit d363c30c5c
14 changed files with 635 additions and 217 deletions

View File

@@ -19,11 +19,22 @@
not sure on the usage of any parameter, read the "Configuration" section
in wiki article about DatabaseService. -->
<database>
<!-- Whether or not the service should try to update and create missing
tables at startup. This should be disabled after the first server start as
it could cause data corruption. -->
<automaticSchemaUpdate>true</automaticSchemaUpdate>
<!-- Configures OrientDB engine - plug-and-play -->
<orientdb>
<!-- The OrientDB storage location -->
<url>local:data/database</url>
<!-- The OrientDB username (local storage must use "admin") -->
<username>admin</username>
<!-- The OrientDB password (local storage must use "admin") -->
<password>admin</password>
</orientdb>
<!-- Configures JDBC engine - requires database server configuration -->
<jdbc>
<!-- Defines the connection URL used by JDBC to connect to the database. -->
<url>jdbc:mysql://localhost/l2jserver2</url>
@@ -32,11 +43,6 @@
<engine>com.l2jserver.service.database.sql.MySQLDatabaseEngine
</engine>
<!-- Whether or not the service should try to update and create missing
tables at startup. This should be disabled after the first server start as
it could cause data corruption. -->
<updateSchema>true</updateSchema>
<!-- The username used to login into the database. NOTE: Try not use
"root" in production servers for security reasons. -->
<username>l2j</username>

View File

@@ -19,6 +19,22 @@
not sure on the usage of any parameter, read the "Configuration" section
in wiki article about DatabaseService. -->
<database>
<!-- Whether or not the service should try to update and create missing
tables at startup. This should be disabled after the first server start as
it could cause data corruption. -->
<automaticSchemaUpdate>true</automaticSchemaUpdate>
<!-- Configures OrientDB engine - plug-and-play -->
<orientdb>
<!-- The OrientDB storage location -->
<url>local:data/database</url>
<!-- The OrientDB username (local storage must use "admin") -->
<username>admin</username>
<!-- The OrientDB password (local storage must use "admin") -->
<password>admin</password>
</orientdb>
<!-- Configures JDBC engine - requires database server configuration -->
<jdbc>
<!-- Defines the connection URL used by JDBC to connect to the database. -->
<url>jdbc:mysql://localhost/l2jserver2</url>
@@ -27,11 +43,6 @@
<engine>com.l2jserver.service.database.sql.MySQLDatabaseEngine
</engine>
<!-- Whether or not the service should try to update and create missing
tables at startup. This should be disabled after the first server start as
it could cause data corruption. -->
<updateSchema>true</updateSchema>
<!-- The username used to login into the database. NOTE: Try not use
"root" in production servers for security reasons. -->
<username>l2j</username>

View File

@@ -20,7 +20,7 @@ import com.google.inject.AbstractModule;
import com.google.inject.Module;
import com.l2jserver.model.id.provider.IDProviderModule;
import com.l2jserver.service.ServiceModule;
import com.l2jserver.service.database.JDBCDAOModule;
import com.l2jserver.service.database.OrientDBDAOModule;
/**
* The game server Google Guice {@link Module}.
@@ -32,6 +32,6 @@ public class GameServerModule extends AbstractModule {
protected void configure() {
install(new ServiceModule());
install(new IDProviderModule());
install(new JDBCDAOModule());
install(new OrientDBDAOModule());
}
}

View File

@@ -30,7 +30,7 @@ import com.l2jserver.service.core.threading.ThreadServiceImpl;
import com.l2jserver.service.core.vfs.Java7VFSService;
import com.l2jserver.service.core.vfs.VFSService;
import com.l2jserver.service.database.DatabaseService;
import com.l2jserver.service.database.GameServerJDBCDatabaseService;
import com.l2jserver.service.database.GameServerOrientDatabaseService;
import com.l2jserver.service.game.AttackService;
import com.l2jserver.service.game.AttackServiceImpl;
import com.l2jserver.service.game.admin.AdministratorService;
@@ -89,7 +89,7 @@ public class ServiceModule extends AbstractModule {
bind(CacheService.class).to(SoftCacheService.class)
.in(Scopes.SINGLETON);
bind(DatabaseService.class).to(GameServerJDBCDatabaseService.class)
bind(DatabaseService.class).to(GameServerOrientDatabaseService.class)
.in(Scopes.SINGLETON);
bind(WorldIDService.class).to(CachedWorldIDService.class).in(
Scopes.SINGLETON);

View File

@@ -17,8 +17,6 @@
package com.l2jserver.service.database;
import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;
import com.google.inject.Inject;
import com.l2jserver.model.game.CharacterShortcut.ShortcutType;
@@ -112,17 +110,20 @@ public class GameServerJDBCDatabaseService extends AbstractSQLDatabaseService
}
@Override
protected void ensureDatabaseSchema(Connection conn) throws SQLException,
IOException {
updateSchema(conn, QActorSkill.actorSkill);
updateSchema(conn, QCharacter.character);
updateSchema(conn, QCharacterFriend.characterFriend);
updateSchema(conn, QCharacterShortcut.characterShortcut);
updateSchema(conn, QClan.clan);
updateSchema(conn, QItem.item);
updateSchema(conn, QLogChat.logChat);
if (updateSchema(conn, QNPC.npc)) {
importData(vfsService.resolve("data/static/npc.csv"), QNPC.npc);
public void updateSchemas() {
updateSchema(QActorSkill.actorSkill);
updateSchema(QCharacter.character);
updateSchema(QCharacterFriend.characterFriend);
updateSchema(QCharacterShortcut.characterShortcut);
updateSchema(QClan.clan);
updateSchema(QItem.item);
updateSchema(QLogChat.logChat);
if (updateSchema(QNPC.npc)) {
try {
importData(vfsService.resolve("data/static/npc.csv"), QNPC.npc);
} catch (IOException e) {
throw new DatabaseException(e);
}
}
}
}

View File

@@ -82,20 +82,19 @@ public class GameServerOrientDatabaseService extends
}
@Override
protected void ensureDatabaseSchema() {
createSchema(QActorSkill.actorSkill);
createSchema(QCharacter.character);
createSchema(QCharacterFriend.characterFriend);
createSchema(QCharacterShortcut.characterShortcut);
createSchema(QClan.clan);
createSchema(QItem.item);
createSchema(QLogChat.logChat);
if (createSchema(QNPC.npc)) {
public void updateSchemas() {
updateSchema(QActorSkill.actorSkill);
updateSchema(QCharacter.character);
updateSchema(QCharacterFriend.characterFriend);
updateSchema(QCharacterShortcut.characterShortcut);
updateSchema(QClan.clan);
updateSchema(QItem.item);
updateSchema(QLogChat.logChat);
if (updateSchema(QNPC.npc)) {
try {
importData(Paths.get("data/static/npc.csv"), QNPC.npc);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
throw new DatabaseException(e);
}
}
}

View File

@@ -23,15 +23,14 @@ public class QActorSkill extends RelationalPathBase<Skill> {
@ColumnSize(10)
public final NumberPath<Integer> actorId = createNumber("actor_id",
Integer.class);
@ColumnSize(6)
public final NumberPath<Integer> skillId = createNumber("skill_id",
Integer.class);
@ColumnSize(4)
public final NumberPath<Integer> level = createNumber("level",
Integer.class);
@ColumnSize(6)
public final NumberPath<Integer> skillId = createNumber("skill_id",
Integer.class);
public final PrimaryKey<Skill> primary = createPrimaryKey(actorId, skillId);
public QActorSkill(String variable) {