Class TableManager

java.lang.Object
tk.airshipcraft.commonlib.db.TableManager

public class TableManager extends Object

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 Details

    • TableManager

      public TableManager(SqlConnectionManager connectionManager)
      Creates a new TableManager instance with a specified connection manager.
      Parameters:
      connectionManager - The SqlConnectionManager responsible for providing database connections.
  • Method Details

    • registerPluginTableConfiguration

      public void registerPluginTableConfiguration(ITableConfiguration config)
      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 the ITableConfiguration.getTableCreationCommands() method for each registered configuration and executes the returned SQL commands to create the necessary tables.