Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,30 @@ jobs:
test:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
rails-version: ["7.2", "8.0", "8.1"]
ruby-version: ["4.0"]
postgres-version: ["16"]
include:
# Edge Rails
- rails-version: edge
ruby-version: "4.0"
postgres-version: "16"
allow-failure: true
# Oldest supported combo
- rails-version: "7.2"
ruby-version: "3.1"
postgres-version: "14"
# Latest everything
- rails-version: "8.1"
ruby-version: "4.0"
postgres-version: "18"

services:
postgres:
image: postgres:16
image: postgres:${{ matrix.postgres-version }}
env:
POSTGRES_PASSWORD: postgres
ports:
Expand All @@ -27,13 +48,17 @@ jobs:
PGHOST: localhost
PGUSER: postgres
PGPASSWORD: postgres
RAILS_VERSION: ${{ matrix.rails-version }}

steps:
- uses: actions/checkout@v4

- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.3"
bundler-cache: true
ruby-version: ${{ matrix.ruby-version }}

- run: rm -f Gemfile.lock && bundle install

- run: bundle exec rake test

continue-on-error: ${{ matrix.allow-failure || false }}
9 changes: 9 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,14 @@ source "https://rubygems.org"

gemspec

rails_version = ENV["RAILS_VERSION"]
if rails_version == "edge"
gem "activerecord", github: "rails/rails"
gem "railties", github: "rails/rails"
elsif rails_version
gem "activerecord", "~> #{rails_version}.0"
gem "railties", "~> #{rails_version}.0"
end

gem "rake"
gem "minitest"
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ PATH
remote: .
specs:
activerecord-postgresql-branched (0.4.1)
activerecord (>= 7.1)
activerecord (>= 7.2)
pg
railties (>= 7.1)
railties (>= 7.2)

GEM
remote: https://rubygems.org/
Expand Down
4 changes: 2 additions & 2 deletions activerecord-postgresql-branched.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
spec.files = Dir["lib/**/*", "LICENSE", "README.md", "CHANGELOG.md"]
spec.require_paths = ["lib"]

spec.add_dependency "activerecord", ">= 7.1"
spec.add_dependency "railties", ">= 7.1"
spec.add_dependency "activerecord", ">= 7.2"
spec.add_dependency "railties", ">= 7.2"
spec.add_dependency "pg"
end
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Adapter < ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
SHADOW_SKIP = %i[create_join_table drop_join_table].freeze

# Methods with custom shadow handling outside the generic loop.
SHADOW_HANDLED = %i[rename_table].freeze
SHADOW_HANDLED = %i[rename_table drop_table create_table].freeze

# Everything else with a table param gets the generic wrapper.
# Shadow#call is idempotent — if the table doesn't exist in
Expand Down
8 changes: 6 additions & 2 deletions test/ddl_coverage_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,8 @@ def test_remove_unique_constraint
# --- Generic constraint DDL ---

def test_validate_constraint
skip "Added in Rails 8.1" unless ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.method_defined?(:validate_constraint)

conn = connect(branch: "main")
conn.add_check_constraint :orders, "amount > 0", name: "orders_amount_positive", validate: false

Expand All @@ -313,6 +315,8 @@ def test_validate_constraint
end

def test_remove_constraint
skip "Added in Rails 8.1" unless ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.method_defined?(:remove_constraint)

conn = connect(branch: "main")
conn.add_check_constraint :orders, "amount > 0", name: "orders_amount_positive"

Expand Down Expand Up @@ -544,7 +548,7 @@ def test_rename_enum
conn.create_enum :status, %w[draft published]

conn = reconnect(branch: "feature/ren-enum")
conn.rename_enum :status, :article_status
conn.rename_enum :status, to: :article_status

assert enum_exists_in_schema?(conn, "branch_feature_ren_enum", "article_status")
assert enum_exists_in_schema?(conn, "public", "status"),
Expand Down Expand Up @@ -600,7 +604,7 @@ def test_rename_enum_value
index_exists? index_name index_name_exists? indexes
inherited_table_names
pk_and_sequence_for primary_key primary_keys
reset_pk_sequence! serial_sequence set_pk_sequence!
reset_column_sequences! reset_pk_sequence! serial_sequence set_pk_sequence!
table_alias_for table_comment table_exists? table_options table_partition_definition
unique_constraint_options unique_constraints
update_table_definition
Expand Down
Loading