Beispiel #1
0
 public Table(
     Namespace namespace, Identifier physicalTableName, String subselect, boolean isAbstract) {
   this.catalog = namespace.getPhysicalName().getCatalog();
   this.schema = namespace.getPhysicalName().getSchema();
   this.name = physicalTableName;
   this.subselect = subselect;
   this.isAbstract = isAbstract;
 }
  @Override
  protected NameSpaceTablesInformation performTablesMigration(
      Metadata metadata,
      DatabaseInformation existingDatabase,
      ExecutionOptions options,
      Dialect dialect,
      Formatter formatter,
      Set<String> exportIdentifiers,
      boolean tryToCreateCatalogs,
      boolean tryToCreateSchemas,
      Set<Identifier> exportedCatalogs,
      Namespace namespace,
      GenerationTarget[] targets) {
    final NameSpaceTablesInformation tablesInformation =
        new NameSpaceTablesInformation(
            metadata.getDatabase().getJdbcEnvironment().getIdentifierHelper());

    if (schemaFilter.includeNamespace(namespace)) {
      createSchemaAndCatalog(
          existingDatabase,
          options,
          dialect,
          formatter,
          tryToCreateCatalogs,
          tryToCreateSchemas,
          exportedCatalogs,
          namespace,
          targets);
      final NameSpaceTablesInformation tables = existingDatabase.getTablesInformation(namespace);
      for (Table table : namespace.getTables()) {
        if (schemaFilter.includeTable(table) && table.isPhysicalTable()) {
          checkExportIdentifier(table, exportIdentifiers);
          final TableInformation tableInformation = tables.getTableInformation(table);
          if (tableInformation == null) {
            createTable(table, dialect, metadata, formatter, options, targets);
          } else if (tableInformation != null && tableInformation.isPhysicalTable()) {
            tablesInformation.addTableInformation(tableInformation);
            migrateTable(table, tableInformation, dialect, metadata, formatter, options, targets);
          }
        }
      }

      for (Table table : namespace.getTables()) {
        if (schemaFilter.includeTable(table) && table.isPhysicalTable()) {
          final TableInformation tableInformation = tablesInformation.getTableInformation(table);
          if (tableInformation == null
              || (tableInformation != null && tableInformation.isPhysicalTable())) {
            applyIndexes(table, tableInformation, dialect, metadata, formatter, options, targets);
            applyUniqueKeys(
                table, tableInformation, dialect, metadata, formatter, options, targets);
          }
        }
      }
    }
    return tablesInformation;
  }
 @Override
 public boolean includeNamespace(Namespace namespace) {
   // exclude schema "the_schema_2"
   Identifier identifier = namespace.getName().getSchema();
   if (identifier != null) {
     return !"the_schema_2".equals(identifier.getText());
   }
   return true;
 }