Class TableSchema
java.lang.Object
group.worldstandard.pudel.api.database.TableSchema
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();
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder class for constructingTableSchemainstances.static final recordRepresents the definition of a database column within a table schema.static final recordRepresents the definition of an index in a database table schema. -
Method Summary
Modifier and TypeMethodDescriptionstatic TableSchema.BuilderCreate a new schema builder.Returns the list of column definitions associated with this table schema.Returns the list of index definitions associated with this table schema.Returns the name of the database table associated with this schema.
-
Method Details
-
getTableName
Returns the name of the database table associated with this schema.- Returns:
- the table name
-
getColumns
Returns the list of column definitions associated with this table schema.- Returns:
- a list of
TableSchema.ColumnDefinitionobjects representing the columns of the table
-
getIndexes
Returns the list of index definitions associated with this table schema.- Returns:
- a list of
TableSchema.IndexDefinitionobjects representing the indexes of the table
-
builder
Create a new schema builder.- Parameters:
tableName- the table name (will be prefixed automatically)- Returns:
- a new builder
-