use of org.jooq.Meta in project jOOQ by jOOQ.
the class VersionImpl method init.
private static final Meta init(DSLContext ctx) {
Meta result = ctx.meta("");
// TODO: Instead of reusing interpreter search path, we should have some dedicated
// configuration for this.
// TODO: Should this be moved in DSLContext.meta()?
List<InterpreterSearchSchema> searchPath = ctx.settings().getInterpreterSearchPath();
for (InterpreterSearchSchema schema : searchPath) result = result.apply(createSchema(schema(name(schema.getCatalog(), schema.getSchema()))));
return result;
}
use of org.jooq.Meta in project jOOQ by jOOQ.
the class MigrationImpl method revertUntrackedQueries.
private final Queries revertUntrackedQueries(Set<Schema> includedSchemas) {
Commit currentCommit = currentCommit();
Meta currentMeta = currentCommit.meta();
Meta existingMeta = dsl().meta().filterSchemas(includedSchemas::contains);
Set<Schema> expectedSchemas = new HashSet<>();
expectedSchemas.addAll(lookup(from().meta().getSchemas()));
expectedSchemas.addAll(lookup(to().meta().getSchemas()));
expectedSchemas.retainAll(includedSchemas);
schemaLoop: for (Schema schema : existingMeta.getSchemas()) {
if (!includedSchemas.contains(schema))
continue schemaLoop;
// TODO Why is this qualification necessary?
existingMeta = existingMeta.apply(dropTableIfExists(schema.getQualifiedName().append(CHANGELOG.getUnqualifiedName())).cascade());
if (!expectedSchemas.contains(schema))
existingMeta = existingMeta.apply(dropSchemaIfExists(schema).cascade());
else
currentMeta = currentMeta.apply(createSchemaIfNotExists(schema));
}
return existingMeta.migrateTo(currentMeta);
}
use of org.jooq.Meta in project jOOQ by jOOQ.
the class CatalogMetaImpl method filterSchemas.
static final Meta filterSchemas(Configuration configuration, Set<Schema> schemas) {
Map<Name, Catalog> c = new LinkedHashMap<>();
Map<Name, List<Schema>> mapping = new LinkedHashMap<>();
for (Schema schema : schemas) mapping.computeIfAbsent(nameOrDefault(schema.getCatalog()), k -> new ArrayList<>()).add(schema);
for (Schema schema : schemas) c.computeIfAbsent(nameOrDefault(schema.getCatalog()), k -> new CatalogImpl(k) {
@Override
public List<Schema> getSchemas() {
return mapping.get(getQualifiedName());
}
});
return filterCatalogs(configuration, new LinkedHashSet<>(c.values())).filterSchemas(schemas::contains);
}
Aggregations