mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Collect the DB schemas in the model via MTable
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package io.ebeaninternal.dbmigration.model;
|
||||
|
||||
import io.ebeaninternal.dbmigration.ddlgeneration.platform.DdlHelp;
|
||||
import io.ebeaninternal.dbmigration.ddlgeneration.platform.SplitColumns;
|
||||
import io.ebeaninternal.dbmigration.migration.AddColumn;
|
||||
import io.ebeaninternal.dbmigration.migration.AddHistoryTable;
|
||||
import io.ebeaninternal.dbmigration.migration.AddTableComment;
|
||||
@@ -34,15 +33,12 @@ import static io.ebeaninternal.dbmigration.ddlgeneration.platform.SplitColumns.s
|
||||
* <p>
|
||||
* This effectively represents a table, its columns and all associated
|
||||
* constraints, foreign keys and indexes.
|
||||
* </p>
|
||||
* <p>
|
||||
* Migrations can be applied to this such that it represents the state
|
||||
* of a given table after various migrations have been applied.
|
||||
* </p>
|
||||
* <p>
|
||||
* This table model can also be derived from the EbeanServer bean descriptor
|
||||
* and associated properties.
|
||||
* </p>
|
||||
*/
|
||||
public class MTable {
|
||||
|
||||
@@ -420,6 +416,11 @@ public class MTable {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getSchema() {
|
||||
int pos = name.indexOf('.');
|
||||
return pos == -1 ? null : name.substring(0, pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if this table is a 'Draft' table.
|
||||
*/
|
||||
|
||||
@@ -24,6 +24,8 @@ import java.util.Collection;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
/**
|
||||
* Holds all the tables, views, indexes etc that represent the model.
|
||||
@@ -33,6 +35,8 @@ import java.util.Map;
|
||||
*/
|
||||
public class ModelContainer {
|
||||
|
||||
private final Set<String> schemas = new TreeSet<>();
|
||||
|
||||
/**
|
||||
* All the tables in the model.
|
||||
*/
|
||||
@@ -50,6 +54,13 @@ public class ModelContainer {
|
||||
public ModelContainer() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the schemas.
|
||||
*/
|
||||
public Set<String> getSchemas() {
|
||||
return schemas;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the model contains tables that are partitioned.
|
||||
*/
|
||||
@@ -310,6 +321,10 @@ public class ModelContainer {
|
||||
if (table.isPartitioned()) {
|
||||
partitionedTables.add(table);
|
||||
}
|
||||
String schema = table.getSchema();
|
||||
if (schema != null) {
|
||||
schemas.add(schema);
|
||||
}
|
||||
return tables.put(table.getName(), table);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user