Class TableSchema

java.lang.Object
group.worldstandard.pudel.api.database.TableSchema

public final class TableSchema extends Object
Schema definition for a plugin database table.

All tables automatically include an 'id' column (BIGSERIAL PRIMARY KEY) and 'created_at', 'updated_at' timestamp columns.

Example:


TableSchema schema = TableSchema.builder("user_settings")
    .column("user_id", ColumnType.BIGINT, false)
    .column("setting_name", ColumnType.STRING, 100, false)
    .column("setting_value", ColumnType.TEXT, true)
    .column("enabled", ColumnType.BOOLEAN, false, "true")
    .index("user_id")
    .uniqueIndex("user_id", "setting_name")
    .build();

  • Method Details

    • getTableName

      public String getTableName()
      Returns the name of the database table associated with this schema.
      Returns:
      the table name
    • getColumns

      public List<TableSchema.ColumnDefinition> getColumns()
      Returns the list of column definitions associated with this table schema.
      Returns:
      a list of TableSchema.ColumnDefinition objects representing the columns of the table
    • getIndexes

      public List<TableSchema.IndexDefinition> getIndexes()
      Returns the list of index definitions associated with this table schema.
      Returns:
      a list of TableSchema.IndexDefinition objects representing the indexes of the table
    • builder

      public static TableSchema.Builder builder(String tableName)
      Create a new schema builder.
      Parameters:
      tableName - the table name (will be prefixed automatically)
      Returns:
      a new builder