From 474ccc9fc4afa98b3b17b588e4100926cbbe2df7 Mon Sep 17 00:00:00 2001 From: Pistos Date: Tue, 18 Oct 2011 21:57:15 -0400 Subject: [PATCH] Set photos_id_seq properly for PostgreSQL (re: recent "MovePhotosToTheirOwnTable" migration, which neglected to do this). --- .../20111019013244_postgresql_photos_id_seq_init.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 db/migrate/20111019013244_postgresql_photos_id_seq_init.rb diff --git a/db/migrate/20111019013244_postgresql_photos_id_seq_init.rb b/db/migrate/20111019013244_postgresql_photos_id_seq_init.rb new file mode 100644 index 000000000..e0c1cb6e1 --- /dev/null +++ b/db/migrate/20111019013244_postgresql_photos_id_seq_init.rb @@ -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