Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jqr/postgres_sequence_support

Support for manipulating PostgreSQL sequences from ActiveRecord.
https://github.com/jqr/postgres_sequence_support

postgresql rails ruby

Last synced: 11 days ago
JSON representation

Support for manipulating PostgreSQL sequences from ActiveRecord.

Awesome Lists containing this project

README

        

= 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

http://rdoc.info/projects/jqr/postgres_sequence_support

Homepage:: http://github.com/jqr/postgres_sequence_support
License:: Copyright (c) 2008 Elijah Miller , released under the MIT license.