CXC-DB-DDL

 view release on metacpan or  search on metacpan

lib/CXC/DB/DDL.pm  view on Meta::CPAN

package CXC::DB::DDL;

use v5.26;
use strict;
use warnings;

our $VERSION = '0.21';

# ABSTRACT: DDL for table creation, based on SQL::Translator::Schema

use DBI::Const::GetInfoType;
use List::Util   qw( first notall all );
use Scalar::Util qw( blessed );
use Hash::Ordered;
use SQL::Translator::Schema;
use SQL::Translator::Schema::Table;

use Ref::Util qw( is_arrayref is_plain_hashref);
use CXC::DB::DDL::Util 'sqlt_entity_map', 'db_version';
use CXC::DB::DDL::Failure;
use CXC::DB::DDL::Table;
use CXC::DB::DDL::Constants '-all';
use Type::Params    qw( signature_for );
use Types::Standard qw( ArrayRef Bool Dict Enum HashRef InstanceOf Object Optional Str Slurpy );

use Moo;
use Feature::Compat::Try;
use experimental 'signatures', 'postderef', 'declared_refs', 'refaliasing';

use constant AutoCommit => 'AutoCommit';

use namespace::clean;

# use after namespace::clean to avoid cleaning out important bits.
use MooX::StrictConstructor;

use constant TABLE_CLASS => 'CXC::DB::DDL::Table';

my sub wrap_producers;

my sub coerce_table_arrayref ( $class, $array ) {
    require Module::Load;
    Module::Load::load( $class->table_class );
    Hash::Ordered->new(
        map {
            my $table = $class->table_class->new( $_ );
            $table->name, $table
        } $array->@*,
    );
}

has _tables => (
    is       => 'ro',
    init_arg => 'tables',
    isa      => InstanceOf( ['Hash::Ordered'] ),
    coerce   => 1,
    default  => sub { Hash::Ordered->new },
    handles  => [qw( get set exists )],
);





















( run in 2.083 seconds using v1.01-cache-2.11-cpan-98e64b0badf )