Set photos_id_seq properly for PostgreSQL (re: recent "MovePhotosToTheirOwnTable" migration, which neglected to do this).
This commit is contained in:
parent
924e18887a
commit
474ccc9fc4
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