# package ARDB::Prepare;

use strict;
use warnings;

my $replace_flag = shift @ARGV;

use ARDB;

my $ardb_object = new ARDB;


my $sql_object = $ardb_object -> {sql_object};

my $relations_object = $ardb_object -> {relations};

$relations_object -> delete_table
 if ( $replace_flag );
$relations_object -> create_table;

foreach my $table_ref ( values %{ $ardb_object -> {config} -> {tables} } )
 {
  print $table_ref -> {name}, " ($table_ref)\n";
  $table_ref -> perform_delete ( $sql_object )
   if ( $replace_flag );
  $table_ref -> perform_create ( $sql_object );
  print "created ", $table_ref->{name}, "\n";
 }

1;
