diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 76358457..d5bebcf3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,8 +37,10 @@ jobs: test: runs-on: ubuntu-latest strategy: + fail-fast: false matrix: - crdb: [v23.2.0] + # https://www.cockroachlabs.com/docs/releases/release-support-policy + crdb: [v22.2, v23.1, v23.2] ruby: [head] name: Test (crdb=${{ matrix.crdb }} ruby=${{ matrix.ruby }}) steps: @@ -54,7 +56,18 @@ jobs: - name: Install and Start Cockroachdb run: | # Download CockroachDB - wget -qO- https://binaries.cockroachdb.com/cockroach-${{ matrix.crdb }}.linux-amd64.tgz | tar xvz + readonly full_version_url=$( + wget -qO- https://www.cockroachlabs.com/docs/releases/${{ matrix.crdb }} | + grep -Eo 'https://binaries.cockroachdb.com/cockroach-${{ matrix.crdb }}.\d+.linux-amd64.tgz' | + head -1 + ) + echo '*****************************************************************' + wget -qO- https://www.cockroachlabs.com/docs/releases/${{ matrix.crdb }} | grep -Eo 'https://binaries.cockroachdb.com/cockroach-${{ matrix.crdb }}.\d+.linux-amd64.tgz' + echo '*****************************************************************' + wget -qO- https://www.cockroachlabs.com/docs/releases/${{ matrix.crdb }} | grep -o 'https://binaries.cockroachdb.com/cockroach-${{ matrix.crdb }}.[0-9]+.linux-amd64.tgz' + echo '*****************************************************************' + echo "Downloading $full_version_url" + wget -qO- "$full_version_url" | tar xvz export PATH=./cockroach-${{ matrix.crdb }}.linux-amd64/:$PATH readonly urlfile=cockroach-url diff --git a/bin/start-cockroachdb b/bin/start-cockroachdb index 4b0ddd0c..a4268c37 100755 --- a/bin/start-cockroachdb +++ b/bin/start-cockroachdb @@ -9,7 +9,7 @@ pid_file="$root_dir/tmp/cockroach.pid" log_file="$root_dir/tmp/cockroachdb.log" mkdir -p "$root_dir/tmp" -[[ -f "$pid_file" ]] && kill -9 $(cat "$pid_file") +[[ -f "$pid_file" ]] && kill -9 $(cat "$pid_file") || true rm -f "$pid_file" if ! (( ${+commands[cockroach]} )); then diff --git a/lib/active_record/connection_adapters/cockroachdb_adapter.rb b/lib/active_record/connection_adapters/cockroachdb_adapter.rb index 95d22577..7be8b133 100644 --- a/lib/active_record/connection_adapters/cockroachdb_adapter.rb +++ b/lib/active_record/connection_adapters/cockroachdb_adapter.rb @@ -154,6 +154,18 @@ def max_transaction_retries @max_transaction_retries ||= @config.fetch(:max_transaction_retries, 3) end + def get_database_version + major, minor, patch = query_value("SHOW crdb_version").match(/v(\d+).(\d+).(\d+)/)[1..].map(&:to_i) + major * 100 * 100 + minor * 100 + patch + end + undef :postgresql_version + alias :cockroachdb_version :database_version + + def supports_datetime_with_precision? + # https://github.com/cockroachdb/cockroach/pull/111400 + database_version >= 23_01_13 + end + def supports_ddl_transactions? false end