NAME

DBIO::DuckDB::DDL - Generate DuckDB DDL from DBIO Result classes

VERSION

version 0.900007

DESCRIPTION

DBIO::DuckDB::DDL generates a DuckDB DDL script from a DBIO::Schema class hierarchy. It is the desired-state side of the test-deploy-and- compare strategy used by DBIO::DuckDB::Deploy.

my $ddl = DBIO::DuckDB::DDL->install_ddl($schema_class_or_instance);

The output is plain SQL, suitable for executing one statement at a time against a fresh DuckDB database. Emits CREATE SEQUENCE (one per integer auto-increment column, START 1000000), CREATE TABLE (inline columns, primary key, unique constraints), CREATE INDEX and CREATE VIEW for non-virtual views. Foreign keys are not emitted (see docs/adr/0001-foreign-keys-omitted-from-install-ddl.md).

Indexes come from the canonical declaration of the result source (idx, indices; index_declarations_for('duckdb')) and from a hand-written duckdb_indexes class method; on the same name the canonical one wins. The own block driver => { duckdb => { expression => ... } } gives an expression index: the value is the whole list between the parentheses, as DuckDB takes it ('lower(b)', 'a, lower(b)'), and stands in for columns. DuckDB has neither partial indexes nor index types, so a where or any other key, a type other than unique and any options throw (docs/adr/0008-index-declarations-are-read-canonically.md).

METHODS

install_ddl

my $ddl = DBIO::DuckDB::DDL->install_ddl($schema);

Returns the full installation DDL as a single string.

source_schemas

my @schemas = DBIO::DuckDB::DDL->source_schemas($schema);

The schemas other than main that the tables of the sources live in: the other of a source declared table('other.t'), sorted, each once. DBIO::DuckDB::Deploy hands them to DBIO::DuckDB::Introspect, which reads only those besides main.

AUTHOR

DBIO Authors

COPYRIGHT AND LICENSE

Copyright (C) 2026 DBIO Authors

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.