DBIx-Admin-CreateTable-2.11/0000755000175000017500000000000014006673517013611 5ustar ronronDBIx-Admin-CreateTable-2.11/Changelog.ini0000644000175000017500000000754614006673515016213 0ustar ronron[Module] Name=DBIx::Admin::CreateTable Changelog.Creator=Module::Metadata::Changes V 2.12 Changelog.Parser=Config::IniFiles V 3.000003 [V 2.11] Date=2021-02-04T15:13:00 Comments= < 0.pod.t, test.t => 1.test.t) - Add t/2.syntax.error.t - Only run tests in t/2.syntax.error.t if $DBI_DSN, $DBI_USER and $DBI_PASS are defined - Remove eval - Localize RaiseError in drop_table(), so as to not error when table does not exist - Make create_table return DBI's errstr() on fail or '' on success, so result can be tested - Make drop_table return '' on success, so result can be tested (in t/2.syntax.error.t) - Remove FindBin::Real from list of required modules EOT [V 1.04] Date=2007-08-23T15:31:00 Comments= < 0.pod.t, test.t => 1.test.t) - Add t/2.syntax.error.t - Only run tests in t/2.syntax.error.t if $DBI_DSN, $DBI_USER and $DBI_PASS are defined - Remove eval - Localize RaiseError in drop_table(), so as to not error when table does not exist - Make create_table return DBI's errstr() on fail or '' on success, so result can be tested - Make drop_table return '' on success, so result can be tested (in t/2.syntax.error.t) - Remove FindBin::Real from list of required modules 1.04 2007-08-23T15:31:00 - Expand docs even more - Rename generate_sequence_name() to generate_primary_sequence_name() 1.03 2007-08-15T13:58:00 - Expand docs per method with tables documenting behaviour per database vendor 1.02 2006-06-09T14:54:00 - Patch sequence handling code to work with Oracle 1.01 2006-05-16T14:09:00 - Add methods reset_all_sequences and reset_sequence 1.00 2006-05-08T14:50:00 - Original versionDBIx-Admin-CreateTable-2.11/MANIFEST0000644000175000017500000000061614006673517014745 0ustar ronronChangelog.ini Changes lib/DBIx/Admin/CreateTable.pm LICENSE Makefile.PL MANIFEST This list of files MANIFEST.SKIP README scripts/pod2html.sh t/00.versions.t t/00.versions.tx t/load.t t/syntax.error.t t/version.t xt/author/pod.t META.yml Module YAML meta-data (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker) DBIx-Admin-CreateTable-2.11/MANIFEST.SKIP0000644000175000017500000000115314006672647015512 0ustar ronron# Avoid version control files. ,v$ \B\.cvsignore$ \B\.git\b \B\.gitignore\b \B\.svn\b \bCVS\b \bRCS\b # Avoid Makemaker generated and utility files. \bblib \bblibdirs$ \bpm_to_blib$ \bMakefile$ \bMakeMaker-\d # Avoid Module::Build generated and utility files. \b_build \bBuild$ \bBuild.bat$ # Avoid Devel::Cover generated files \bcover_db # Avoid temp and backup files. ~$ \#$ \.# \.bak$ \.old$ \.rej$ \.tmp$ # Avoid OS-specific files/dirs # Mac OSX metadata \B\.DS_Store # Mac OSX SMB mount metadata files \B\._ # Avoid UltraEdit files. \.prj$ \.pui$ ^MYMETA.yml$ ^MYMETA\.json$ ^DBIx-Admin-CreateTable-.* DBIx-Admin-CreateTable-2.11/xt/0000755000175000017500000000000014006673517014244 5ustar ronronDBIx-Admin-CreateTable-2.11/xt/author/0000755000175000017500000000000014006673517015546 5ustar ronronDBIx-Admin-CreateTable-2.11/xt/author/pod.t0000444000175000017500000000020512307221601016471 0ustar ronronuse Test::More; eval "use Test::Pod 1.45"; plan skip_all => "Test::Pod 1.45 required for testing POD" if $@; all_pod_files_ok(); DBIx-Admin-CreateTable-2.11/lib/0000755000175000017500000000000014006673517014357 5ustar ronronDBIx-Admin-CreateTable-2.11/lib/DBIx/0000755000175000017500000000000014006673517015145 5ustar ronronDBIx-Admin-CreateTable-2.11/lib/DBIx/Admin/0000755000175000017500000000000014006673517016175 5ustar ronronDBIx-Admin-CreateTable-2.11/lib/DBIx/Admin/CreateTable.pm0000644000175000017500000006746414006673515020725 0ustar ronronpackage DBIx::Admin::CreateTable; use strict; use warnings; use Moo; has db_vendor => ( is => 'rw', default => sub{return ''}, required => 0, ); has dbh => ( is => 'rw', isa => sub{die "The 'dbh' parameter to new() is mandatory\n" if (! $_[0])}, default => sub{return ''}, required => 0, ); has primary_index_name => ( is => 'rw', default => sub{return {} }, required => 0, ); has sequence_name => ( is => 'rw', default => sub{return {} }, required => 0, ); has verbose => ( is => 'rw', default => sub{return 0}, required => 0, ); our $VERSION = '2.11'; # ----------------------------------------------- sub BUILD { my($self) = @_; $self -> db_vendor(uc $self -> dbh -> get_info(17) ); # SQL_DBMS_NAME. print STDERR __PACKAGE__, '. Db vendor ' . $self -> db_vendor . ". \n" if ($self -> verbose); } # End of BUILD. # -------------------------------------------------- sub create_table { my($self, $sql, $arg) = @_; my($table_name) = $sql; $table_name =~ s/^\s*create\s+table\s+([a-z_0-9]+).+$/$1/is; $arg = {} if (! defined $arg); $$arg{$table_name} = {} if (! defined $$arg{$table_name}); $$arg{$table_name}{no_sequence} = 0 if (! defined $$arg{$table_name}{no_sequence}); if (! $$arg{$table_name}{no_sequence}) { my($sequence_name) = $self -> generate_primary_sequence_name($table_name); if ($sequence_name) { my($sql) = "create sequence $sequence_name"; $self -> dbh -> do($sql); print STDERR __PACKAGE__, ". SQL: $sql. \n" if ($self -> verbose); if ($self -> dbh -> errstr() ) { return $self -> dbh -> errstr(); # Failure. } print STDERR __PACKAGE__, ". Created sequence '$sequence_name'. \n" if ($self -> verbose); } } $self -> dbh -> do($sql); print STDERR __PACKAGE__, ". SQL: $sql. \n" if ($self -> verbose); if ($self -> dbh -> errstr() ) { return $self -> dbh -> errstr(); # Failure. } print STDERR __PACKAGE__, ". Created table '$table_name'. \n" if ($self -> verbose); return ''; # Success. } # End of create_table. # -------------------------------------------------- sub drop_table { my($self, $table_name, $arg) = @_; my($sequence_name) = $self -> generate_primary_sequence_name($table_name); # Turn off RaiseError so we don't error if the sequence and table being deleted do not exist. # We do this by emulating local $$dbh{RaiseError}. my($dbh) = $self -> dbh; my($raise_error) = $$dbh{RaiseError}; $$dbh{RaiseError} = 0; $self -> dbh($dbh); $arg = {} if (! defined $arg); $$arg{$table_name} = {} if (! defined $$arg{$table_name}); $$arg{$table_name}{no_sequence} = 0 if (! defined $$arg{$table_name}{no_sequence}); my($sql); # For Oracle, drop the sequence before dropping the table. if ( ($self -> db_vendor eq 'ORACLE') && ! $$arg{$table_name}{no_sequence}) { $sql = "drop sequence $sequence_name"; $self -> dbh -> do($sql); print STDERR __PACKAGE__, ". SQL: $sql. \n" if ($self -> verbose); print STDERR __PACKAGE__, ". Dropped sequence '$sequence_name'. \n" if ($self -> verbose); } $sql = "drop table $table_name"; $self -> dbh -> do($sql); print STDERR __PACKAGE__, ". SQL: $sql. \n" if ($self -> verbose); print STDERR __PACKAGE__, ". Dropped table '$table_name'. \n" if ($self -> verbose); # For Postgres, drop the sequence after dropping the table. if ( ($self -> db_vendor eq 'POSTGRESQL') && ! $$arg{$table_name}{no_sequence}) { $sql = "drop sequence $sequence_name"; $self -> dbh -> do($sql); print STDERR __PACKAGE__, ". SQL: $sql. \n" if ($self -> verbose); print STDERR __PACKAGE__, ". Dropped sequence '$sequence_name'. \n" if ($self -> verbose); } # Undo local $$dbh{RaiseError}. $$dbh{RaiseError} = $raise_error; $self -> dbh($dbh); return ''; } # End of drop_table. # -------------------------------------------------- sub generate_primary_index_name { my($self, $table_name) = @_; my($hashref) = $self -> primary_index_name; if (! $$hashref{$table_name}) { $$hashref{$table_name} = $self -> db_vendor eq 'POSTGRESQL' ? "${table_name}_pkey" : ''; # MySQL, Oracle, SQLite. $self -> primary_index_name($hashref); } return $$hashref{$table_name}; } # End of generate_primary_index_name. # -------------------------------------------------- sub generate_primary_key_sql { my($self, $table_name) = @_; my($sequence_name) = $self -> generate_primary_sequence_name($table_name); my($primary_key) = ($self -> db_vendor eq 'MYSQL') ? 'integer primary key auto_increment' : ($self -> db_vendor eq 'SQLITE') ? 'integer primary key autoincrement' : $self -> db_vendor eq 'ORACLE' ? 'integer primary key' : "integer primary key default nextval('$sequence_name')"; # Postgres. return $primary_key; } # End of generate_primary_key_sql. # -------------------------------------------------- sub generate_primary_sequence_name { my($self, $table_name) = @_; my($hashref) = $self -> sequence_name; if (! $$hashref{$table_name}) { $$hashref{$table_name} = $self -> db_vendor =~ /(?:MYSQL|SQLITE)/ ? '' : "${table_name}_id_seq"; # Oracle, Postgres. $self -> sequence_name($hashref); } return $$hashref{$table_name}; } # End of generate_primary_sequence_name. # ----------------------------------------------- # Assumption: This code is only called in the case # of Oracle and Postgres, and after importing data # for all tables from a XML file (say). # The mechanism used to import from XML does not # activate the sequences because the primary keys # are included in the data being imported. # So, we have to reset the current values of the # sequences up from their default values of 1 to # the number of records in the corresponding table. # If not, then the next call to nextval() would # return a value of 2, which is already in use. sub reset_all_sequences { my($self, $arg) = @_; if ($self -> db_vendor ne 'MYSQL') { $self -> reset_sequence($_, $arg) for keys %{$self -> sequence_name}; } } # End of reset_all_sequences. # ----------------------------------------------- sub reset_sequence { my($self, $table_name, $arg) = @_; $arg = {} if (! defined $arg); $$arg{$table_name} = {} if (! defined $$arg{$table_name}); $$arg{$table_name}{no_sequence} = 0 if (! defined $$arg{$table_name}{no_sequence}); if (! $$arg{$table_name}{no_sequence}) { my($sequence_name) = $self -> generate_primary_sequence_name($table_name); my($sth) = $self -> dbh -> prepare("select count(*) from $table_name"); $sth -> execute(); my($max) = $sth -> fetch(); $max = $$max[0] || 0; my($sql) = "select setval('$sequence_name', $max)"; $sth -> finish(); $self -> dbh -> do($sql); print STDERR __PACKAGE__, ". SQL: $sql. \n" if ($self -> verbose); print STDERR __PACKAGE__, ". Reset table '$table_name', sequence '$sequence_name' to $max. \n" if ($self -> verbose); } } # End of reset_sequence. # -------------------------------------------------- 1; =head1 NAME DBIx::Admin::CreateTable - Create and drop tables, primary indexes, and sequences =head1 Synopsis #!/usr/bin/env perl use strict; use warnings; use DBI; use DBIx::Admin::CreateTable; # ---------------- my($dbh) = DBI -> connect(...); my($creator) = DBIx::Admin::CreateTable -> new(dbh => $dbh, verbose => 1); my($table_name) = 'test'; $creator -> drop_table($table_name); my($primary_key) = $creator -> generate_primary_key_sql($table_name); $creator -> create_table(<. =head1 Description C is a pure Perl module. Database vendors supported: MySQL, Oracle, Postgres, SQLite. Assumptions: =over 4 =item Every table has a primary key =item The primary key is a unique, non-null, integer =item The primary key is a single column =item The primary key column is called 'id' =item If a primary key has a corresponding auto-created index, the index is called 't_pkey' This is true for Postgres, where declaring a column as a primary key automatically results in the creation of an associated index for that column. The index is named after the table, not after the column. =item If a table 't' (with primary key 'id') has an associated sequence, the sequence is called 't_id_seq' This is true for both Oracle and Postgres, which use sequences to populate primary key columns. The sequences are named after both the table and the column. =back =head1 Constructor and initialization new(...) returns an object of type C. This is the class contructor. Usage: DBIx::Admin::CreateTable -> new(). This method takes a set of parameters. Only the dbh parameter is mandatory. For each parameter you wish to use, call new as new(param_1 => value_1, ...). =over 4 =item dbh This is a database handle, returned from the DBI connect() call. This parameter is mandatory. There is no default. =item verbose This is 0 or 1, to turn off or on printing of progress statements to STDERR. This parameter is optional. The default is 0. =back =head1 Method: create_table($sql, $arg) Returns '' (empty string) if successful and DBI errstr() if there is an error. $sql is the SQL to create the table. $arg is an optional hash ref of options per table. The keys are table names. The only sub-key at the moment is... =over 4 =item no_sequence $arg = {$table_name_1 => {no_sequence => 1}, $table_name_2 => {no_sequence => 1} }; can be used to tell create_table not to create a sequence for the given table. You would use this on a CGI::Session-type table called 'sessions', for example, when using Oracle or Postgres. With MySQL there would be no sequence anyway. You would also normally use this on a table called 'log'. The reason for this syntax is so you can use the same hash ref in a call to reset_all_sequences. =back Usage with CGI::Session: my($creator) = DBIx::Admin::CreateTable -> new(dbh => $dbh, verbose => 1); my($table_name) = 'sessions'; my($type) = $creator -> db_vendor() eq 'ORACLE' ? 'long' : 'text'; $creator -> drop_table($table_name); $creator -> create_table(< {no_sequence => 1} }); create table $table_name ( id char(32) primary key, a_session $type not null ) SQL Typical usage: my($creator) = DBIx::Admin::CreateTable -> new(dbh => $dbh, verbose => 1); my($table_name) = 'test'; my($primary_key) = $creator -> generate_primary_key_sql($table_name); $creator -> drop_table($table_name); $creator -> create_table(< 0} | {no_sequence => 1} | +----------|------------------------------|--------------------+ | MySQL | Create table | Create table | +----------|------------------------------|--------------------+ | Oracle | Create sequence before table | Create table | +----------|------------------------------|--------------------+ | Postgres | Create sequence before table | Create table | +----------|------------------------------|--------------------+ | SQLite | Create table | Create table | +----------|------------------------------|--------------------+ SQL: Method: create_table($table_name, $arg). Comment: SQL generated. Sequence: See generate_primary_sequence_name($table_name). +----------|-------------------------------------------------------------------------------------+ | | SQL for $$arg{$table_name} | | Vendor | {no_sequence => 0} | {no_sequence => 1} | +----------|------------------------------------------|------------------------------------------+ | MySQL | create table $table_name | create table $table_name | | | (id integer primary key | (id integer auto_increment | | | auto_increment, | primary key, | | | data varchar(255) ) | data varchar(255) ) | +----------|------------------------------------------|------------------------------------------+ | Oracle | create sequence ${table_name}_id_seq & | | | | create table $table_name | create table $table_name | | | (id integer primary key, | (id integer primary key, | | | data varchar(255) ) | data varchar(255) ) | +----------|------------------------------------------|------------------------------------------+ | Postgres | create sequence ${table_name}_id_seq & | | | | create table $table_name | create table $table_name | | | (id integer primary key | (id integer primary key | | | default nextval("${table_name}_id_seq"), | default nextval("${table_name}_id_seq"), | | | data varchar(255) ) | data varchar(255) ) | +----------|------------------------------------------|------------------------------------------+ | SQLite | create table $table_name | create table $table_name | | | (id integer primary key | (id integer autoincrement | | | autoincrement, | primary key, | | | data varchar(255) ) | data varchar(255) ) | +----------|------------------------------------------|------------------------------------------+ =head1 Method: db_vendor() Returns an upper-case string identifying the database vendor. Return string: Method: db_vendor(db_vendor). Comment: Value returned. +----------|------------+ | Vendor | String | +----------|------------+ | MySQL | MYSQL | +----------|------------+ | Oracle | ORACLE | +----------|------------+ | Postgres | POSTGRESQL | +----------|------------+ | SQLite | SQLITE | +----------|------------+ =head1 Method: drop_table($table_name, $arg) Returns '' (empty string). $table_name is the name of the table to drop. $arg is an optional hash ref of options, the same as for C. Action: Method: drop_table($table_name, $arg). Comment: Deletion of tables and sequences. Sequence: See generate_primary_sequence_name($table_name). +----------|-------------------------------------------------+ | | Action for $$arg{$table_name} | | Vendor | {no_sequence => 0} | {no_sequence => 1} | +----------|----------------------------|--------------------+ | MySQL | Drop table | Drop table | +----------|----------------------------|--------------------+ | Oracle | Drop sequence before table | Drop table | +----------|----------------------------|--------------------+ | Postgres | Drop sequence after table | Drop table | +----------|----------------------------|--------------------+ | SQLite | Drop table | Drop table | +----------|----------------------------|--------------------+ SQL: Method: drop_table($table_name, $arg). Comment: SQL generated. Sequence: See generate_primary_sequence_name($table_name). +----------|---------------------------------------------------------------+ | | SQL for $$arg{$table_name} | | Vendor | {no_sequence => 0} | {no_sequence => 1} | +----------|--------------------------------------|------------------------+ | MySQL | drop table $table_name | drop table $table_name | +----------|--------------------------------------|------------------------+ | Oracle | drop sequence ${table_name}_id_seq & | | | | drop table $table_name | drop table $table_name | +----------|--------------------------------------|------------------------+ | Postgres | drop table $table_name & | drop table $table_name | | | drop sequence ${table_name}_id_seq | | +----------|--------------------------------------|------------------------+ | SQLite | drop table $table_name | drop table $table_name | +----------|--------------------------------------|------------------------+ Note: drop_table() turns off RaiseError so we do not error if the sequence and table being deleted do not exist. This is new in V 2.00. =head1 Method: generate_primary_index_name($table_name) Returns the name of the index corresponding to the primary key for the given table. The module does not call this method. SQL: Method: generate_primary_index_name($table_name). Comment: Generation of name of the index for the primary key. +----------|--------------------+ | Vendor | SQL | +----------|--------------------+ | MySQL | | +----------|--------------------+ | Oracle | | +----------|--------------------+ | Postgres | ${table_name}_pkey | +----------|--------------------+ | SQLite | | +----------|--------------------+ =head1 Method: generate_primary_key_sql($table_name) Returns partial SQL for declaring the primary key for the given table. See the Synopsis for how to use this method. SQL: Method: generate_primary_key_sql($table_name). Comment: Generation of partial SQL for primary key. Sequence: See generate_primary_sequence_name($table_name). +----------|-----------------------------------------------------+ | Vendor | SQL | +----------|-----------------------------------------------------+ | MySQL | integer primary key auto_increment | +----------|-----------------------------------------------------+ | Oracle | integer primary key | +----------|-----------------------------------------------------+ | Postgres | integer primary key default nextval($sequence_name) | +----------|-----------------------------------------------------+ | SQLite | integer primary key autoincrement | +----------|-----------------------------------------------------+ =head1 Method: generate_primary_sequence_name($table_name) Returns the name of the sequence used to populate the primary key of the given table. SQL: Method: generate_primary_sequence_name($table_name). Comment: Generation of name for sequence. +----------|----------------------+ | Vendor | SQL | +----------|----------------------+ | MySQL | | +----------|----------------------+ | Oracle | ${table_name}_id_seq | +----------|----------------------+ | Postgres | ${table_name}_id_seq | +----------|----------------------+ | SQLite | | +----------|----------------------+ =head1 Method: reset_all_sequences($arg) Returns nothing. Resets the primary key sequence for all tables, except those marked by $arg as not having a sequence. Note: This method only works if called against an object which knows the names of all tables and sequences. This means you must have called at least one of these, for each table: =over =item create_table =item drop_table =item generate_primary_key_sql =item generate_primary_sequence_name =back $arg is an optional hash ref of options, the same as for C. Summary: Method: reset_all_sequences($arg). Comment: Reset all sequences. +----------|-------------------------------------------------------+ | Vendor | Action | +----------|-------------------------------------------------------+ | MySQL | Do nothing | +----------|-------------------------------------------------------+ | Oracle | Call reset_sequence($table_name, $arg) for all tables | +----------|-------------------------------------------------------+ | Postgres | Call reset_sequence($table_name, $arg) for all tables | +----------|-------------------------------------------------------+ | SQLite | Do nothing | +----------|-------------------------------------------------------+ =head1 Method: reset_sequence($table_name, $arg) Returns nothing. Resets the primary key sequence for the given table, except if it is marked by $arg as not having a sequence. $arg is an optional hash ref of options, the same as for C. Summary: Method: reset_sequence($table_name, $arg). Comment: Reset one sequence. Sequence: The value of the sequence is set to the number of records in the table. +----------|-----------------------------------------+ | | Action for $$arg{$table_name} | | Vendor | {no_sequence => 0} | {no_sequence => 1} | +----------|--------------------|--------------------+ | MySQL | Do nothing | Do nothing | +----------|--------------------|--------------------+ | Oracle | Set sequence value | Do nothing | +----------|--------------------|--------------------+ | Postgres | Set sequence value | Do nothing | +----------|--------------------|--------------------+ | SQLite | Do nothing | Do nothing | +----------|--------------------|--------------------+ =head1 FAQ =head2 Which versions of the servers did you test? Versions as at 2014-03-07 +----------|------------+ | Vendor | V | +----------|------------+ | MariaDB | 5.5.36 | +----------|------------+ | Oracle | 10.2.0.1.0 | (Not tested for years) +----------|------------+ | Postgres | 9.1.12 | +----------|------------+ | SQLite | 3.7.17 | +----------|------------+ =head2 Do all database servers accept the same 'create table' commands? No. You have been warned. References for 'Create table': L. L. L. Consider these: create table one ( id integer primary key autoincrement, data varchar(255) ) $engine create table two ( id integer primary key autoincrement, one_id integer not null, data varchar(255), foreign key(one_id) references one(id) ) $engine Putting the 'foreign key' clause at the end makes it a table constraint. Some database servers, e.g. MySQL and Postgres, allow you to attach it to a particular column, as explained next. =over 4 =item o MySQL The creates work as given, where $engine eq 'engine = innodb'. Further, you can re-order the clauses in the 2nd create: create table two ( id integer primary key autoincrement, one_id integer not null, foreign key(one_id) references one(id), data varchar(255) ) $engine This also works, where $engine eq 'engine = innodb'. However, if you use: create table two ( id integer primary key autoincrement, one_id integer not null references one(id), data varchar(255) ) $engine Then the 'references' (foreign key) clause is parsed but discarded, even with 'engine = innodb'. =item o Postgres The creates work as given, where $engine = ''. And you can re-order the clauses, as in the first example for MySQL. =item o SQLite The creates work as given, where $engine = ''. But if you re-order the clauses: create table two ( id integer primary key autoincrement, one_id integer not null, foreign key(one_id) references one(id), data varchar(255) ) $engine Then you get a syntax error. However, if you use: create table two ( id integer primary key autoincrement, one_id integer not null references one(id), data varchar(255) ) $engine Then the 'references' (foreign key) clause is parsed, and it does create a foreign key relationship. =back Do not forget this when using SQLite: $dbh -> do('pragma foreign_keys = on') if ($dsn =~ /SQLite/i); =head2 Do I include the name of an auto-populated column in an insert statement? Depends on the server. Some databases, e.g. Postgres, do I want the name of the primary key in the insert statement if the server is to generate a value for a column. SQL for insert: Comment: SQL for insertion of rows containing auto-populated values. Sequence: See generate_primary_sequence_name($table_name). +----------|-----------------------------------------------------------------------+ | Vendor | SQL | +----------|-----------------------------------------------------------------------+ | MySQL | insert into $table_name (data) values (?) | +----------|-----------------------------------------------------------------------+ | Oracle | insert into $table_name (id, data) values ($sequence_name.nextval, ?) | +----------|-----------------------------------------------------------------------+ | Postgres | insert into $table_name (data) values (?) | +----------|-----------------------------------------------------------------------+ | SQLite | insert into $table_name (id, data) values (undef, ?) | +----------|-----------------------------------------------------------------------+ =head2 Do I have to use a sequence to populate a primary key? Well, no, actually. See next question. =head2 How to I override the auto-populated value for a primary key column? By including the name and the value in the insert statement. SQL for insert: Comment: SQL for insertion of rows overriding auto-populated values. +----------|--------------------------------------------------+ | Vendor | SQL | +----------|--------------------------------------------------+ | MySQL | insert into $table_name (id, data) values (?, ?) | +----------|--------------------------------------------------+ | Oracle | insert into $table_name (id, data) values (?, ?) | +----------|--------------------------------------------------+ | Postgres | insert into $table_name (id, data) values (?, ?) | +----------|--------------------------------------------------+ | SQLite | insert into $table_name (id, data) values (?, ?) | +----------|--------------------------------------------------+ =head2 Are primary keys always not null and unique? Yes. All servers document primary key as meaning both non null and unique. =head2 See Also L. L. =head1 Version Numbers Version numbers < 1.00 represent development versions. From 1.00 up, they are production versions. =head1 Repository L =head1 Support Bugs should be reported via the CPAN bug tracker at L =head1 Author C was written by Ron Savage Iron@savage.net.auE> in 2006. L =head1 Copyright Australian copyright (c) 2006, Ron Savage. All Programs of mine are 'OSI Certified Open Source Software'; you can redistribute them and/or modify them under the terms of the Artistic or the GPL licences, copies of which is available at: http://www.opensource.org/licenses/index.html =cut DBIx-Admin-CreateTable-2.11/Makefile.PL0000644000175000017500000000316014006673474015565 0ustar ronronuse strict; use warnings; use ExtUtils::MakeMaker; print "The tests in t/syntax.error.t will only by run if \$DBI_DSN, \$DBI_USER and \$DBI_PASS are defined. \n"; # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. my(%params) = ( ($] ge '5.005') ? ( AUTHOR => 'Ron Savage (ron@savage.net.au)', ABSTRACT => 'Create and drop tables, primary indexes, and sequences', ) : (), clean => { FILES => 'blib/* Makefile MANIFEST DBIx-Admin-CreateTable-*' }, dist => { COMPRESS => 'gzip', SUFFIX => 'gz' }, DISTNAME => 'DBIx-Admin-CreateTable', LICENSE => 'perl', NAME => 'DBIx::Admin::CreateTable', PL_FILES => {}, PREREQ_PM => { 'DBI' => 0, 'Moo' => 1.004002, 'strict' => 0, 'warnings' => 0, }, TEST_REQUIRES => { 'Test::More' => 1.001014, 'Test::Version' => 1.002003, }, VERSION_FROM => 'lib/DBIx/Admin/CreateTable.pm', INSTALLDIRS => 'site', EXE_FILES => [], ); if ( ($ExtUtils::MakeMaker::VERSION =~ /^\d\.\d\d$/) && ($ExtUtils::MakeMaker::VERSION > 6.30) ) { $params{LICENSE} = 'perl'; } if ($ExtUtils::MakeMaker::VERSION ge '6.46') { $params{META_MERGE} = { 'meta-spec' => { version => 2, }, resources => { bugtracker => { web => 'https://github.com/ronsavage/DBIx-Admin-CreateTable/issues', }, license => 'http://opensource.org/licenses/Perl', repository => { type => 'git', url => 'https://github.com/ronsavage/DBIx-Admin-CreateTable.git', web => 'https://github.com/ronsavage/DBIx-Admin-CreateTable', }, }, }; } WriteMakefile(%params); DBIx-Admin-CreateTable-2.11/META.yml0000644000175000017500000000156514006673517015071 0ustar ronron--- abstract: 'Create and drop tables, primary indexes, and sequences' author: - 'Ron Savage (ron@savage.net.au)' build_requires: ExtUtils::MakeMaker: '0' Test::More: '1.001014' Test::Version: '1.002003' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 7.58, CPAN::Meta::Converter version 2.150010' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: DBIx-Admin-CreateTable no_index: directory: - t - inc requires: DBI: '0' Moo: '1.004002' strict: '0' warnings: '0' resources: bugtracker: https://github.com/ronsavage/DBIx-Admin-CreateTable/issues license: http://opensource.org/licenses/Perl repository: https://github.com/ronsavage/DBIx-Admin-CreateTable.git version: '2.11' x_serialization_backend: 'CPAN::Meta::YAML version 0.018' DBIx-Admin-CreateTable-2.11/scripts/0000755000175000017500000000000014006673517015300 5ustar ronronDBIx-Admin-CreateTable-2.11/scripts/pod2html.sh0000555000175000017500000000022212307221601017343 0ustar ronron#!/bin/bash # $DR is my web server's doc root. pod2html.pl -i lib/DBIx/Admin/CreateTable.pm -o $DR/Perl-modules/html/DBIx/Admin/CreateTable.html DBIx-Admin-CreateTable-2.11/README0000444000175000017500000000340012307221601014445 0ustar ronronREADME file for DBIx::Admin::CreateTable. See also: Changes.txt. Warning: WinZip 8.1 and 9.0 both contain an 'accidental' bug which stops them recognizing POSIX-style directory structures in valid tar files. You are better off using a reliable tool such as InfoZip: ftp://ftp.info-zip.org/pub/infozip/ 1 Installing from a Unix-like distro ------------------------------------ shell>gunzip DBIx-Admin-CreateTable-1.00-1.00.tgz shell>tar mxvf DBIx-Admin-CreateTable-1.00-1.00.tar On Unix-like systems, assuming you have installed Module::Build V 0.25+: shell>perl Build.PL shell>./Build shell>./Build test shell>./Build install On MS Windows-like systems, assuming you have installed Module::Build V 0.25+: shell>perl Build.PL shell>perl Build shell>perl Build test shell>perl Build install Alternately, without Module::Build, you do this: Note: 'make' on MS Windows-like systems may be called 'nmake' or 'dmake'. shell>perl Makefile.PL shell>make shell>make test shell>su (for Unix-like systems) shell>make install shell>exit (for Unix-like systems) On all systems: Run CreateTable.pm through you favourite pod2html translator. If you are using my fancy-pom2.pl, with its 'default.css' file installed in /apache2/htdocs/assets/css/, you'd do: shell>perl fancy-pom2.pl html -css CreateTable.pm > /apache2/htdocs/assets/CreateTable.html or perhaps something like: shell>perl fancy-pom2.pl html -css CreateTable.pm > /perl/html/site/lib/DBIx/Admin/CreateTable.html 2 Installing from an ActiveState distro --------------------------------------- shell>unzip DBIx-Admin-CreateTable-1.00-1.00.zip shell>ppm install --location=. DBIx-Admin-CreateTable-1.00 shell>del DBIx-Admin-CreateTable-1.00-1.00.ppd shell>del PPM-DBIx-Admin-CreateTable-1.00-1.00.tar.gz DBIx-Admin-CreateTable-2.11/LICENSE0000644000175000017500000004740714006671326014626 0ustar ronronTerms of Perl itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" ---------------------------------------------------------------------------- The General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS ---------------------------------------------------------------------------- The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End DBIx-Admin-CreateTable-2.11/t/0000755000175000017500000000000014006673517014054 5ustar ronronDBIx-Admin-CreateTable-2.11/t/00.versions.tx0000644000175000017500000000077314006671464016525 0ustar ronron#/usr/bin/env perl use strict; use warnings; # I tried 'require'-ing modules but that did not work. use <: $module_name :>; # For the version #. use Test::More; <: $module_list_1 :> # ---------------------- pass('All external modules loaded'); my(@modules) = qw / <: $module_list_2 :> /; diag "Testing <: $module_name :> V $<: $module_name :>::VERSION"; for my $module (@modules) { no strict 'refs'; my($ver) = ${$module . '::VERSION'} || 'N/A'; diag "Using $module V $ver"; } done_testing; DBIx-Admin-CreateTable-2.11/t/00.versions.t0000644000175000017500000000105314006673515016324 0ustar ronron#/usr/bin/env perl use strict; use warnings; # I tried 'require'-ing modules but that did not work. use DBIx::Admin::CreateTable; # For the version #. use Test::More; use DBI; use Moo; use strict; use warnings; # ---------------------- pass('All external modules loaded'); my(@modules) = qw / DBI Moo strict warnings /; diag "Testing DBIx::Admin::CreateTable V $DBIx::Admin::CreateTable::VERSION"; for my $module (@modules) { no strict 'refs'; my($ver) = ${$module . '::VERSION'} || 'N/A'; diag "Using $module V $ver"; } done_testing; DBIx-Admin-CreateTable-2.11/t/version.t0000444000175000017500000000026512307221601015710 0ustar ronronuse strict; use warnings; use Test::More; use Test::Version 'version_all_ok', {is_strict => 1}; # ------------------------------------------------ version_all_ok; done_testing; DBIx-Admin-CreateTable-2.11/t/load.t0000444000175000017500000000014612307221601015140 0ustar ronronuse Test::More tests => 1; # ------------------------ BEGIN{ use_ok('DBIx::Admin::CreateTable'); } DBIx-Admin-CreateTable-2.11/t/syntax.error.t0000444000175000017500000000200612307221601016674 0ustar ronronuse strict; use warnings; use DBI; use DBIx::Admin::CreateTable; use Test::More; # -------------------------------------------------- my($dbh); eval{$dbh = DBI -> connect($ENV{'DBI_DSN'}, $ENV{'DBI_USER'}, $ENV{'DBI_PASS'}, {PrintError => 0, RaiseError => 0})}; if ($dbh) { plan (tests => 2); } else { plan (skip_all => '$DBI_DSN etc not defined, so skipping all tests in syntax.error.pl'); } my($creator) = DBIx::Admin::CreateTable -> new(dbh => $dbh, verbose => 0); my($db_vendor) = $creator -> db_vendor(); my($table_name) = 'test'; my($primary_index_name) = $creator -> generate_primary_index_name($table_name); my($primary_key_sql) = $creator -> generate_primary_key_sql($table_name); ok($creator -> drop_table($table_name) eq '', "Drop table '$table_name' worked (table may not have existed)"); ok($creator -> create_table(<