ActiveRecord で接続している PostgreSQL のバージョンを確認する


Rails console で以下のようにすると良い。

[1] pry(main)> ActiveRecord::Base.connection.instance_eval { postgresql_version }
=> 90504

この値の解釈については pg の gem の中身を参照。
https://github.com/ged/ruby-pg/blob/1f274f68c16f1af1c642db1b9d3d28aef169dc84/ext/pg_connection.c#L775-L785

/*
 * call-seq:
 *   conn.server_version -> Integer
 *
 * The number is formed by converting the major, minor, and revision
 * numbers into two-decimal-digit numbers and appending them together.
 * For example, version 7.4.2 will be returned as 70402, and version
 * 8.1 will be returned as 80100 (leading zeroes are not shown). Zero
 * is returned if the connection is bad.
 *
 */

とのことなのでこれは 9.5.4 ということになるようです。