436 |
foreach my $class (keys %{$schema->{classes}}) { |
foreach my $class (keys %{$schema->{classes}}) { |
437 |
|
|
438 |
my $classdef = $classes->{$class}; |
my $classdef = $classes->{$class}; |
|
|
|
439 |
my $tabledef = $tables->{ $classdef->{table} } ||= {}; |
my $tabledef = $tables->{ $classdef->{table} } ||= {}; |
440 |
my $cols = $tabledef->{COLS} ||= {}; |
my $cols = $tabledef->{COLS} ||= {}; |
441 |
|
|
442 |
$cols->{ $schema->{sql}{id_col} } = $schema->{sql}{id}; |
$cols->{ $schema->{sql}{id_col} } = $schema->{sql}{id}; |
443 |
|
|
444 |
$cols->{ $schema->{sql}{class_col} || 'type' } = $schema->{sql}{cid} if $self->{ROOT_TABLES}{$classdef->{table}}; |
$cols->{ $schema->{sql}{class_col} || 'type' } = $schema->{sql}{cid} if $self->{ROOT_TABLES}{$classdef->{table}}; |
445 |
|
|
446 |
|
$tables->{$class}->{SQL} = $classdef->{sql} if $classdef->{sql}; |
447 |
|
|
448 |
foreach my $typetag (keys %{$classdef->{members}}) |
foreach my $typetag (keys %{$classdef->{members}}) |
449 |
{ |
{ |
601 |
{ |
{ |
602 |
my $def = $tables->{$table}; |
my $def = $tables->{$table}; |
603 |
my $cols = $def->{COLS}; |
my $cols = $def->{COLS}; |
604 |
|
my $sql = $def->{SQL}; |
605 |
|
|
606 |
my @base_cols; |
my @base_cols; |
|
|
|
607 |
my $id_col = $schema->{sql}{id_col}; |
my $id_col = $schema->{sql}{id_col}; |
608 |
my $class_col = $schema->{sql}{class_col} || 'type'; |
my $class_col = $schema->{sql}{class_col} || 'type'; |
609 |
|
my $table_type = $sql->{table_type} || $schema->{sql}{table_type}; |
610 |
|
|
611 |
push @base_cols, "$id_col $schema->{sql}{id} NOT NULL,\n PRIMARY KEY( id )" if exists $cols->{$id_col}; |
push @base_cols, "$id_col $schema->{sql}{id} NOT NULL,\n PRIMARY KEY( id )" if exists $cols->{$id_col}; |
612 |
push @base_cols, "$class_col $schema->{sql}{cid} NOT NULL" if exists $cols->{$class_col}; |
push @base_cols, "$class_col $schema->{sql}{cid} NOT NULL" if exists $cols->{$class_col}; |
616 |
|
|
617 |
$do->("CREATE TABLE $table\n(\n ", |
$do->("CREATE TABLE $table\n(\n ", |
618 |
join( ",\n ", @base_cols, map { "$_ $cols->{$_}" } keys %$cols ), |
join( ",\n ", @base_cols, map { "$_ $cols->{$_}" } keys %$cols ), |
619 |
"\n)" ); |
"\n)", ($table_type ? " TYPE=$table_type" : '') ); |
620 |
} |
} |
621 |
|
|
622 |
|
my $table_type = $schema->{sql}{table_type}; |
623 |
|
my $control_type = ($table_type ? " TYPE=$table_type" : ''); |
624 |
my $control = $schema->{control}; |
my $control = $schema->{control}; |
625 |
|
|
626 |
$do->( <<SQL ); |
$do->( <<SQL ); |
631 |
engine_layout INTEGER, |
engine_layout INTEGER, |
632 |
mark INTEGER NOT NULL |
mark INTEGER NOT NULL |
633 |
) |
) |
634 |
|
$control_type |
635 |
SQL |
SQL |
636 |
|
|
637 |
my $info = $engine->get_deploy_info(); |
my $info = $engine->get_deploy_info(); |