#!/usr/bin/env 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 Jifty::DBI::Handle; use Jifty::DBI::SchemaGenerator; my $BaseClass; BEGIN { unless (@ARGV) { die < $BaseClass, sub_name => 'models', instantiate => 'new'; my $handle = Jifty::DBI::Handle->new; $handle->Connect( @CONNECT_ARGS ); my $SG = Jifty::DBI::SchemaGenerator->new($handle); die "Couldn't make SchemaGenerator" unless $SG; for my $model (__PACKAGE__->models) { my $ret = $SG->add_model($model); $ret or die "couldn't add model $model: ".$ret->error_message; } print $SG->create_table_sql_text;