| Class-DBI-DDL documentation | Contained in the Class-DBI-DDL distribution. |
Class::DBI::DDL::Pg - Perform driver dependent work for PostgreSQL
Do not use this package directly. Intead, it will automatically be imported and used by Class::DBI::DDL when the underlying database uses the DBD::Pg driver.
The only method here that works different from the default is
pre_create_table. This method uses the PostgreSQL SERIAL type to perform
auto-increment and sets the sequence method since Class::DBI doesn't
properly handle PostgreSQL auto-numbering.
Andrew Sterling Hanenkamp <sterling@hanenkamp.com>
Copyright 2003 Andrew Sterling Hanenkamp. All Rights Reserved.
This module is free software and is distributed under the same license as Perl itself.
| Class-DBI-DDL documentation | Contained in the Class-DBI-DDL distribution. |
package Class::DBI::DDL::Pg; use 5.008; use strict; use warnings; our $VERSION = '1.01';
sub pre_create_table { my ($class, $self) = @_; # For each column with an auto_increment property, drop that property and # change the type to serial and set sequence to reference this column--this # will only work for a single primary key column... for my $column (@{$self->column_definitions}) { if (grep /^auto_increment$/i, @{$column}[1 .. $#$column]) { $$column[1] = 'serial'; @$column = grep !/^auto_increment$/i, @$column; $self->sequence($self->table."_$$column[0]_seq"); } } } sub post_create_table { } sub pre_drop_table { } sub post_drop_table { }
1