Package tk.airshipcraft.commonlib.db
Class TableManager
java.lang.Object
tk.airshipcraft.commonlib.db.TableManager
The TableManager class manages the creation and updating of database tables
for various plugins using the CommonLib library. It works with implementations
of the ITableConfiguration
interface to execute SQL commands necessary
for setting up and migrating tables.
Use cases include:
- Setting up initial database tables for plugins on startup.
- Managing database migrations when plugins are updated with new schema requirements.
This class ensures that all plugins extending CommonLib have a centralized way to manage their data schemas without needing to implement boilerplate code for database interactions.
- Since:
- 2023-12-27
- Version:
- 1.0.0
- Author:
- notzune
-
Constructor Summary
ConstructorsConstructorDescriptionTableManager
(SqlConnectionManager connectionManager) Creates a new TableManager instance with a specified connection manager. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Registers a plugin's table configuration with the TableManager.void
Sets up the database tables for all registered plugins.
-
Constructor Details
-
TableManager
Creates a new TableManager instance with a specified connection manager.- Parameters:
connectionManager
- The SqlConnectionManager responsible for providing database connections.
-
-
Method Details
-
registerPluginTableConfiguration
Registers a plugin's table configuration with the TableManager. This allows the TableManager to execute the SQL commands provided by the plugin for table creation and migration.- Parameters:
config
- An implementation of the ITableConfiguration interface.
-
setupPluginTables
public void setupPluginTables()Sets up the database tables for all registered plugins. It calls theITableConfiguration.getTableCreationCommands()
method for each registered configuration and executes the returned SQL commands to create the necessary tables.
-