primaryKeyColumns
Return the list of columns that make the primary key.
public class MTable extends Object
This effectively represents a table, its columns and all associated constraints, foreign keys and indexes.
Migrations can be applied to this such that it represents the state of a given table after various migrations have been applied.
This table model can also be derived from the EbeanServer bean descriptor and associated properties.
| Constructor | Description |
|---|---|
MTable(CreateTable createTable) |
Construct for migration.
|
MTable(io.ebeaninternal.server.deploy.BeanDescriptor<?> descriptor) |
|
MTable(String name) |
Construct for element collection or intersection table.
|
| Modifier and Type | Method | Description |
|---|---|---|
void |
addColumn(MColumn column) |
Add a model column (typically from EbeanServer meta data).
|
MColumn |
addColumn(String dbCol,
String columnDefn,
boolean notnull) |
Add a column checking if it already exists and if so return the existing column.
|
void |
addForeignKey(MCompoundForeignKey compoundKey) |
Add a compound foreign key.
|
void |
addForeignKey(String name,
String refTableName,
String indexName,
String columnNames,
String refColumnNames) |
|
void |
addUniqueConstraint(MCompoundUniqueConstraint uniqueConstraint) |
Add a unique constraint.
|
void |
adjustReferences(ModelContainer modelContainer) |
Adjust the references (FK) if it should relate to a draft table.
|
Collection<MColumn> |
allColumns() |
Return all the columns (excluding columns marked as dropped).
|
List<String> |
allHistoryColumns(boolean includeDropped) |
|
void |
apply(AddColumn addColumn) |
Apply AddColumn migration.
|
void |
apply(AlterColumn alterColumn) |
Apply AddColumn migration.
|
void |
apply(DropColumn dropColumn) |
Apply DropColumn migration.
|
void |
apply(RenameColumn renameColumn) |
|
void |
checkDuplicateForeignKeys() |
Check if there are duplicate foreign keys.
|
void |
clearForeignKeyIndexes() |
Clear the indexes on the foreign keys as they are covered by unique constraints.
|
void |
compare(ModelDiff modelDiff,
MTable newTable) |
Compare to another version of the same table to perform a diff.
|
MTable |
createDraftTable() |
Create a copy of this table structure as a 'draft' table.
|
CreateTable |
createTable() |
Return the CreateTable migration for this table.
|
DropTable |
dropTable() |
Return the DropTable migration for this table.
|
MColumn |
getColumn(String name) |
Return the column by name.
|
String |
getComment() |
|
List<MCompoundForeignKey> |
getCompoundKeys() |
|
String |
getIndexTablespace() |
|
String |
getName() |
|
io.ebeaninternal.server.deploy.PartitionMeta |
getPartitionMeta() |
Return the partition meta for this table.
|
String |
getPkName() |
|
String |
getSchema() |
|
String |
getTablespace() |
|
List<MCompoundUniqueConstraint> |
getUniqueConstraints() |
|
String |
getWhenCreatedColumn() |
|
boolean |
isDraft() |
Return true if this table is a 'Draft' table.
|
boolean |
isPartitioned() |
Return true if this table is partitioned.
|
boolean |
isWithHistory() |
|
List<MColumn> |
primaryKeyColumns() |
Return the list of columns that make the primary key.
|
void |
registerPendingDropColumn(String columnName) |
Register a pending un-applied drop column.
|
void |
removeForeignKey(String name) |
|
void |
setComment(String comment) |
|
void |
setPkName(String pkName) |
|
MIndex |
setReusedElementCollection() |
Clear foreign key as this element collection table logically references
back to multiple tables.
|
MTable |
setWithHistory(boolean withHistory) |
|
String |
singlePrimaryKey() |
Return the primary key column if it is a simple primary key.
|
void |
updateCompoundIndices() |
This method adds information which columns are nullable or not to the compound indices.
|
Note that both tables contain @DraftOnly MColumns and these are filtered out later when creating the CreateTable object.
This means this column still needs to be included in history views/triggers etc even though it is not part of the current model.
This can occur when an ManyToMany relates back to itself.