DataMapper out of range value for column ‘id’

If you are reading this, you are (probably) using DataMapper and are having problems like this:

Exception `DataObjects::DataError' at dm-do-adapter/adapter.rb:279
Out of range value for column 'id' at row 1 (code: 1264, sql state: 22003, 
query: INSERT INTO `workspaces` (`id`, `name`) VALUES (2348944937325, 'Stardata S.r.l.')

The problem is that the default field created by DataMapper for an Integer property is a 32bit INT (at least on MySQL 5.5). If you want to store bigger integers you should use the :min and :max parameters, for example:

class Workspace
  include DataMapper::Resource

  property :id, Integer, :key => true, :min => 0, :max => 281474976710656
  property :name, String


Then DataMapper will use a BIGINT for the field.


Dynamic DNS updates for DHCP on Ubuntu 12.04

Configuring your nameserver for dynamic updates for DHCP hosts is a common task, but the online documentation is a bit outdated and incorrect in many ways. Let’s fix it.

A basic DNS configuration will look like this:


include "/etc/bind/named.conf.options";
include "/etc/bind/named.conf.dhcpupdate";
include "/etc/bind/named.conf.local";
include "/etc/bind/named.conf.default-zones";

We added the include named.conf.dhcpupdate to the default file. Let’s see the rest.


options {
        directory "/var/cache/bind";

        forwarders {

        auth-nxdomain no;    # conform to RFC1035
        listen-on-v6 { any; };

We used Google DNS servers as forwarders (it’s a good default).


key dhcpupdate {
  algorithm hmac-md5;
  secret "waZulpdc0rzMahbulbd34C==";

We created the key using:

$ su -
# cd /etc/bind/
# dnssec-keygen -a hmac-md5 -b 128 -n USER dhcpupdate
# cat Kdhcpupdate.+157+31337.key
dhcpupdate. IN KEY 0 3 157 waZulpdc0rzMahbulbd34C==

You should create your own key, otherwise everyone reading this post will be able to tamper with your DNS :)


zone "stardata.lan" {
        type master;
        file "/var/cache/bind/db.stardata.lan";
        allow-update { key dhcpupdate; };

zone "" {
        type master;
        notify no;
        file "/var/cache/bind/db.192";
        allow-update { key dhcpupdate; };

It’s very important that your zone files are in /var/cache/bind/, otherwise AppArmor will deny the write permissions to named and the daemon will not update the zones.


We kept the default for this file and related files (db.root, db.local, db.127, db.0, db.255)


$TTL 7200 ; 2 hours
stardata.lan            IN SOA  gw.stardata.lan. hostmaster.stardata.lan. (
                                2012070901 ; serial
                                3600       ; refresh (1 hour)
                                1800       ; retry (30 minutes)
                                604800     ; expire (1 week)
                                7200       ; minimum (2 hours)
                        NS      gw.stardata.lan.
$ORIGIN stardata.lan.
$TTL 3600 ; 1 hour
dns                     A
gateway                 A
gw                      A
ns                      A

This is a very simple and basic configuration, covering only our DNS server (


$TTL 604800     ; 1 week    IN SOA  gw.stardata.lan. (
                                2012050804 ; serial
                                604800     ; refresh (1 week)
                                86400      ; retry (1 day)
                                2419200    ; expire (4 weeks)
                                604800     ; minimum (1 week)
                        NS      gw.
2                       PTR     gw.stardata.lan.

And this is the reverse zone.

Now, you’ll want to test this configuration. Restart bind (service bind9 restart), then create a PTR and an A record:

$ nsupdate
> server localhost
> key dhcpupdate waZulpdc0rzMahbulbd34C==
> zone
> update add 600 IN PTR provaprova.stardata.lan.
> send
> server localhost
> key dhcpupdate waZulpdc0rzMahbulbd34C==
> zone stardata.lan
> update add provaprova.stardata.lan. 600 IN A

If you don’t have any errors, then you can delete the temp record:

$ nsupdate
> server localhost
> key dhcpupdate waZulpdc0rzMahbulbd34C==
> zone stardata.lan
> update delete provaprova.stardata.lan
> send

If you have any errors, check /var/log/syslog for error messages. I had a NOTZONE error first, because I was using stardata.lan instead of as the zone for the PTR record. I had a SERVFAIL error due to AppArmor denying write permissions on zone files (you should not see this).

Back to DHCP configuration:


ddns-updates on;
ddns-domainname "stardata.lan";
ddns-update-style interim;

key dhcpupdate {
  algorithm hmac-md5;
  secret waZulpdc0rzMahbulbd34C==;

option domain-name "stardata.lan";
option domain-name-servers;
default-lease-time 7200;
max-lease-time 86400;
log-facility local7;

subnet netmask {
  option routers;
  option domain-name-servers;

zone {
  primary ns.stardata.lan;
  key dhcpupdate;

zone stardata.lan {
  primary ns.stardata.lan;
  key dhcpupdate;

The ddns-* and the zone directives enable the DNS updating.

Sources: BIND 9 Server Howto, Dynamic DNS and DHCP – Easy tutorial.