Class TableSchema.Builder

java.lang.Object
group.worldstandard.pudel.api.database.TableSchema.Builder
Enclosing class:
TableSchema

public static class TableSchema.Builder extends Object
Builder class for constructing TableSchema instances. Provides a fluent API for defining table structure including columns and indexes. Validates table and column names according to naming conventions. Table names must start with a lowercase letter and contain only lowercase letters, numbers, and underscores. Column names follow the same rules but cannot be reserved words like 'id', 'created_at', or 'updated_at'.
  • Method Details

    • column

      public TableSchema.Builder column(String name, ColumnType type, boolean nullable)
      Add a column to the schema.
      Parameters:
      name - column name
      type - column type
      nullable - whether the column can be null
      Returns:
      this builder
    • column

      public TableSchema.Builder column(String name, ColumnType type, Integer size, boolean nullable)
      Add a column with a size constraint.
      Parameters:
      name - column name
      type - column type
      size - size/length for VARCHAR, etc.
      nullable - whether the column can be null
      Returns:
      this builder
    • column

      public TableSchema.Builder column(String name, ColumnType type, boolean nullable, String defaultValue)
      Add a column with a default value.
      Parameters:
      name - column name
      type - column type
      nullable - whether the column can be null
      defaultValue - SQL default value expression
      Returns:
      this builder
    • column

      public TableSchema.Builder column(String name, ColumnType type, Integer size, boolean nullable, String defaultValue)
      Add a column with all options.
      Parameters:
      name - column name
      type - column type
      size - size/length (nullable)
      nullable - whether the column can be null
      defaultValue - SQL default value expression (nullable)
      Returns:
      this builder
    • index

      public TableSchema.Builder index(String... columnNames)
      Add an index on one or more columns.
      Parameters:
      columnNames - the columns to index
      Returns:
      this builder
    • uniqueIndex

      public TableSchema.Builder uniqueIndex(String... columnNames)
      Add a unique index on one or more columns.
      Parameters:
      columnNames - the columns for the unique constraint
      Returns:
      this builder
    • build

      public TableSchema build()