Skip to content

Commit 1ca2e8e

Browse files
committed
vector may already be updated
1 parent f03d68b commit 1ca2e8e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

db/migrate/20240611170904_upgrade_pgvector_070.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22

33
class UpgradePgvector070 < ActiveRecord::Migration[7.0]
44
def up
5-
DB.exec("ALTER EXTENSION \"vector\" UPDATE TO '0.7.0';")
5+
minimum_target_version = '0.7.0'
6+
installed_version = DB.exec("SELECT extversion FROM pg_extension WHERE extname = 'vector';").first['extversion']
7+
8+
if GEM::Version.new(installed_version) < GEM::Version.new(minimum_target_version)
9+
DB.exec("ALTER EXTENSION vector UPDATE TO '0.7.0';")
10+
end
611
end
712

813
def down

0 commit comments

Comments
 (0)