Merge pull request #2209 from Pistos/postgresql-set-photos-id-seq
Set photos_id_seq properly for PostgreSQL
This commit is contained in:
commit
edd4352e49
1 changed files with 11 additions and 0 deletions
11
db/migrate/20111019013244_postgresql_photos_id_seq_init.rb
Normal file
11
db/migrate/20111019013244_postgresql_photos_id_seq_init.rb
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
class PostgresqlPhotosIdSeqInit < ActiveRecord::Migration
|
||||
def self.up
|
||||
if postgres?
|
||||
execute "SELECT setval('photos_id_seq', COALESCE( ( SELECT MAX(id)+1 FROM photos ), 1 ) )"
|
||||
end
|
||||
end
|
||||
|
||||
def self.down
|
||||
# No reason or need to migrate this down.
|
||||
end
|
||||
end
|
||||
Loading…
Reference in a new issue