#!/usr/bin/perl use strict; use warnings; # Note: this script does not actually *create* the tables; # however, it needs to connect to the database in order to # get the specific capabilities of your database (like type info). # CHANGE THIS TO FIT YOUR DATABASE: my @CONNECT_ARGS = ( Driver => 'Pg', Database => 'test', Host => 'localhost', User => 'postgres', Password => '', ); use DBIx::SearchBuilder::Handle; use DBIx::SearchBuilder::SchemaGenerator; my $BaseClass; BEGIN { unless (@ARGV) { die < $BaseClass, sub_name => 'models', instantiate => 'new'; my $handle = DBIx::SearchBuilder::Handle->new; $handle->Connect( @CONNECT_ARGS ); my $SG = DBIx::SearchBuilder::SchemaGenerator->new($handle); die "Couldn't make SchemaGenerator" unless $SG; for my $model (__PACKAGE__->models) { my $ret = $SG->AddModel($model); $ret or die "couldn't add model $model: ".$ret->error_message; } print $SG->CreateTableSQLText;