On Mon, Oct 12, 2020 at 7:54 PM Megan A <[email protected]> wrote:

> Yes! That's what I wanted. I must have been confused because to do this
> manually I had to query the "INFORMATION_SCHEMA" table.
>

I see, that's a bit confusing, indeed. For background info: We chose to
re-use the name information_schema, because that's a SQL standard schema
which has been implemented by a few RDBMS, including SQL Server. Our own
version of it also reflects the specification, but in XML format:
https://www.jooq.org/xsd/jooq-meta-3.13.3.xsd

In the grand scheme of things though what I really need is this:
> https://blog.jooq.org/category/migrations/
>
> So I can do to something like this:
>
> ctx.meta(
>     "create table t (i int)"
>   ).diff(ctx.meta(
>     "create table t ("
>   + "i int not null, "
>   + "j int null, "
>   + "primary key (i))"
>   ))
>
> But it looks like that is still in development. So I have to look at what
> columns are in the DB and add the ones that are missing.


Indeed, there's a lot in this area that is still in development. However,
from how you described your use-cases to Rob, I think you can already use
what's there for many of your purposes. The question is: How do you want to
describe your dynamic metadata?

jOOQ can create org.jooq.Meta types from various information sources:

- Generated code (which you don't have). Relevant methods are
DSLContext.meta(Catalog...), meta(Schema...), meta(Table...)
- JDBC DatabaseMetaData. The relevant method is
DSLContext.meta(DatabaseMetaData), or just DSLContext.meta() (if you don't
change the Configuration.metaProvider())
- XML or the InformationSchema classes (both are the same, via JAXB). The
relevant method is DSLContext.meta(InformationSchema)
- DDL in string form, file form, or jOOQ DSL form. The relevant methods are
DSLContext.meta(String...), meta(Source...), meta(Query...)

The Meta.diff() method can then produce DDL for any pair of meta types.

Among all the input formats, perhaps the XML format (or its equivalent Java
version, the InformationSchema) might be the most manageable. You could
maintain an InformationSchema (which you can also extract from other Meta
sources, e.g. via Meta::informationSchema), manipulate it, e.g. by adding
columns to it, and then generate a diff.

The devil is in the details. For example, the XML format might not be able
to handle some vendor specific data types, such as arrays, nor do we
support altering all vendor specific data types, should you need that. But
I think this approach could already get you quite far with jOOQ 3.13 and
soon 3.14. We're always open to feature requests in this area, as this will
be of high strategic value to us in the near future.

Thanks,
Lukas

-- 
You received this message because you are subscribed to the Google Groups "jOOQ 
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jooq-user/CAB4ELO4ggMFTTaTNkAyBuY6QBrTFFs4iWZe3qS0vg8b%2BFuKF%2BQ%40mail.gmail.com.

Reply via email to