[Dbix-class] Problems deploying a Postgres database that uses sequences

Robert Rothenberg robrwo at gmail.com
Sat Aug 11 12:50:39 GMT 2012


I am working on a project that uses DBIx::Class but deploys the database
using an SQL script.  We'd like to use DBix::Class::DeploymentHandler or
(preferably) DBIx::Class::Migration for deploying the databases, and
handling upgrades.

The database in question uses sequences for primary keys.

If we use DBIx::Class's deploy method, the new database will have a similar
schema. Importantly, it will use sequences, e.g. an "id" field will be
defined "integer not null default nextval('table_id_seq'::regclass).

This is all well and good, but we want a better way to handle upgrades (or
possibly downgrades) and load data.

If we use DBIx::Class::Migration, it sets the the primary keys to "serial"
instead.

I imagine substituting the auto-generated
share/migrations/PostgreSQL/deploy/1/001-auto.sql with our original SQL
script might fix that, but, will it be overwritten later by upgrades?

Even worse though: when we populate the database with data, the sequences
(well, "serial" counters) do not seem to be incremented properly, so adding
new records fails.  So is there a way to update sequences when using
DBIx::Class::Migration?

Regards,
Rob



More information about the DBIx-Class mailing list