Skip to content
Support for manipulating PostgreSQL sequences from ActiveRecord.
Ruby
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lib
.gitignore
CHANGELOG
LICENSE
Manifest
README.rdoc
Rakefile
init.rb
postgres_sequence_support.gemspec

README.rdoc

Postgres Sequence Support

Easy manipulation of PostgreSQL sequences from ActiveRecord.

Examples

User.next_id              # => 1
User.current_id           # => 1

c = ActiveRecord::Base.connection
c.set_sequence('users_id_seq', 1000)
c.next_in_sequence('users_id_seq')      # => 1001

# Note : create sequence don't do anything if sequence already exists
c.create_sequence('my_own_seq')
c.next_in_sequence('my_own_seq')        # => 1

# You can specify sequence start
c.create_sequence('my_own_seq', 1001)
c.next_in_sequence('my_own_seq')        # => 1001

# Check if sequence exists
c.sequence_exists?('my_own_seq')        # => true
c.sequence_exists?('my_other_seq')      # => false

# Drop sequence if it exists
c.drop_sequence('my_own_seq')

Install

As a Rails plugin.

./script/plugin install git://github.com/jqr/postgres_sequence_support.git

Prefer gems? Add this to your environment.rb and run the following command.

config.gem 'postgres_sequence_support'

$ rake gems:install

Docs

rdoc.info/projects/jqr/postgres_sequence_support

Homepage

github.com/jqr/postgres_sequence_support

License

Copyright © 2008 Elijah Miller <elijah.miller@gmail.com>, released under the MIT license.

Something went wrong with that request. Please try again.