Module: Sequel::Plugins::UpdatePrimaryKey

Defined in:
lib/sequel/plugins/update_primary_key.rb

Overview

The update_primary_key plugin allows you to modify an object’s primary key and then save the record. Sequel does not work correctly with primary key modifications by default. Sequel is designed to work with surrogate primary keys that never need to be modified, but this plugin makes it work correctly with natural primary keys that may need to be modified. Example:

album = Album[1]
album.id = 2
album.save

Usage:

# Make all model subclasses support primary key updates
# (called before loading subclasses)
Sequel::Model.plugin :update_primary_key

# Make the Album class support primary key updates
Album.plugin :update_primary_key

Defined Under Namespace

Modules: InstanceMethods