Skip to content

Commit

Permalink
Merge f79ee29 into 423fba6
Browse files Browse the repository at this point in the history
  • Loading branch information
urkle committed May 11, 2022
2 parents 423fba6 + f79ee29 commit fe9f7b3
Show file tree
Hide file tree
Showing 19 changed files with 141 additions and 15 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/prs.yml
Expand Up @@ -22,9 +22,12 @@ jobs:
- '2.5'
- '2.7'
- '3.0'
- '3.1'
activerecord:
- '5.2'
- '6.0'
- '6.1'
- '7.0'
db:
- mysql2
- sqlite3
Expand All @@ -34,6 +37,10 @@ jobs:
exclude:
- ruby: '3.0'
activerecord: '5.2'
- ruby: '3.1'
activerecord: '5.2'
- ruby: '2.5'
activerecord: '7.0'
- db: skip
dbversion: skip
include:
Expand All @@ -45,6 +52,10 @@ jobs:
activerecord: '6.0'
db: postgresql
dbversion: '9.6'
- ruby: '2.5'
activerecord: '6.1'
db: postgresql
dbversion: '9.6'
- ruby: '2.7'
activerecord: '5.2'
db: postgresql
Expand All @@ -53,10 +64,38 @@ jobs:
activerecord: '6.0'
db: postgresql
dbversion: '9.6'
- ruby: '2.7'
activerecord: '6.1'
db: postgresql
dbversion: '9.6'
- ruby: '2.7'
activerecord: '7.0'
db: postgresql
dbversion: '9.6'
- ruby: '3.0'
activerecord: '6.0'
db: postgresql
dbversion: '9.6'
- ruby: '3.0'
activerecord: '6.1'
db: postgresql
dbversion: '9.6'
- ruby: '3.0'
activerecord: '7.0'
db: postgresql
dbversion: '9.6'
- ruby: '3.1'
activerecord: '6.0'
db: postgresql
dbversion: '9.6'
- ruby: '3.1'
activerecord: '6.1'
db: postgresql
dbversion: '9.6'
- ruby: '3.1'
activerecord: '7.0'
db: postgresql
dbversion: '9.6'
env:
BUNDLE_GEMFILE: "${{ github.workspace }}/gemfiles/activerecord-${{ matrix.activerecord }}/Gemfile.${{ matrix.db }}"
MYSQL_DB_HOST: 127.0.0.1
Expand Down
8 changes: 8 additions & 0 deletions README.md
Expand Up @@ -154,9 +154,17 @@ SchemaPlus::ForeignKeys is tested on:
<!-- These lines are auto-generated by schema_dev based on schema_dev.yml -->
* ruby **2.5** with activerecord **5.2**, using **mysql2**, **sqlite3** or **postgresql:9.6**
* ruby **2.5** with activerecord **6.0**, using **mysql2**, **sqlite3** or **postgresql:9.6**
* ruby **2.5** with activerecord **6.1**, using **mysql2**, **sqlite3** or **postgresql:9.6**
* ruby **2.7** with activerecord **5.2**, using **mysql2**, **sqlite3** or **postgresql:9.6**
* ruby **2.7** with activerecord **6.0**, using **mysql2**, **sqlite3** or **postgresql:9.6**
* ruby **2.7** with activerecord **6.1**, using **mysql2**, **sqlite3** or **postgresql:9.6**
* ruby **2.7** with activerecord **7.0**, using **mysql2**, **sqlite3** or **postgresql:9.6**
* ruby **3.0** with activerecord **6.0**, using **mysql2**, **sqlite3** or **postgresql:9.6**
* ruby **3.0** with activerecord **6.1**, using **mysql2**, **sqlite3** or **postgresql:9.6**
* ruby **3.0** with activerecord **7.0**, using **mysql2**, **sqlite3** or **postgresql:9.6**
* ruby **3.1** with activerecord **6.0**, using **mysql2**, **sqlite3** or **postgresql:9.6**
* ruby **3.1** with activerecord **6.1**, using **mysql2**, **sqlite3** or **postgresql:9.6**
* ruby **3.1** with activerecord **7.0**, using **mysql2**, **sqlite3** or **postgresql:9.6**

<!-- SCHEMA_DEV: MATRIX - end -->

Expand Down
4 changes: 4 additions & 0 deletions gemfiles/activerecord-6.1/Gemfile.base
@@ -0,0 +1,4 @@
base_gemfile = File.expand_path('../../Gemfile.base', __FILE__)
eval File.read(base_gemfile)

gem "activerecord", ">= 6.1", "< 6.2"
10 changes: 10 additions & 0 deletions gemfiles/activerecord-6.1/Gemfile.mysql2
@@ -0,0 +1,10 @@
base_gemfile = File.expand_path('../Gemfile.base', __FILE__)
eval File.read(base_gemfile), binding, base_gemfile

platform :ruby do
gem "mysql2"
end

platform :jruby do
gem 'activerecord-jdbcmysql-adapter'
end
10 changes: 10 additions & 0 deletions gemfiles/activerecord-6.1/Gemfile.postgresql
@@ -0,0 +1,10 @@
base_gemfile = File.expand_path('../Gemfile.base', __FILE__)
eval File.read(base_gemfile), binding, base_gemfile

platform :ruby do
gem "pg"
end

platform :jruby do
gem 'activerecord-jdbcpostgresql-adapter'
end
10 changes: 10 additions & 0 deletions gemfiles/activerecord-6.1/Gemfile.sqlite3
@@ -0,0 +1,10 @@
base_gemfile = File.expand_path('../Gemfile.base', __FILE__)
eval File.read(base_gemfile), binding, base_gemfile

platform :ruby do
gem "sqlite3"
end

platform :jruby do
gem 'activerecord-jdbcsqlite3-adapter', '>=1.3.0.beta2'
end
4 changes: 4 additions & 0 deletions gemfiles/activerecord-7.0/Gemfile.base
@@ -0,0 +1,4 @@
base_gemfile = File.expand_path('../../Gemfile.base', __FILE__)
eval File.read(base_gemfile)

gem "activerecord", ">= 7.0", "< 7.1"
10 changes: 10 additions & 0 deletions gemfiles/activerecord-7.0/Gemfile.mysql2
@@ -0,0 +1,10 @@
base_gemfile = File.expand_path('../Gemfile.base', __FILE__)
eval File.read(base_gemfile), binding, base_gemfile

platform :ruby do
gem "mysql2"
end

platform :jruby do
gem 'activerecord-jdbcmysql-adapter'
end
10 changes: 10 additions & 0 deletions gemfiles/activerecord-7.0/Gemfile.postgresql
@@ -0,0 +1,10 @@
base_gemfile = File.expand_path('../Gemfile.base', __FILE__)
eval File.read(base_gemfile), binding, base_gemfile

platform :ruby do
gem "pg"
end

platform :jruby do
gem 'activerecord-jdbcpostgresql-adapter'
end
10 changes: 10 additions & 0 deletions gemfiles/activerecord-7.0/Gemfile.sqlite3
@@ -0,0 +1,10 @@
base_gemfile = File.expand_path('../Gemfile.base', __FILE__)
eval File.read(base_gemfile), binding, base_gemfile

platform :ruby do
gem "sqlite3"
end

platform :jruby do
gem 'activerecord-jdbcsqlite3-adapter', '>=1.3.0.beta2'
end
1 change: 0 additions & 1 deletion lib/schema_plus/foreign_keys.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true

require 'schema_plus/core'
require 'schema_plus_compatibility'
require 'valuable'

require_relative 'foreign_keys/version'
Expand Down
Expand Up @@ -4,7 +4,18 @@ module SchemaPlus
module Core
module ActiveRecord
module ConnectionAdapters
module AbstractAdapter
if Gem::Version.new(::ActiveRecord::VERSION::STRING) < Gem::Version.new('6.1')
module AbstractAdapter
module SchemaCreation

def visit_ForeignKeyDefinition(o)
# schema_plus_foreign_keys already implements a superior
# conversion of ForeignKeyDefinitions to SQL
o.to_sql
end
end
end
else
module SchemaCreation

def visit_ForeignKeyDefinition(o)
Expand Down
2 changes: 1 addition & 1 deletion lib/schema_plus/foreign_keys/middleware/dumper.rb
Expand Up @@ -16,7 +16,7 @@ def before(env)
@inline_fks = Hash.new{ |h, k| h[k] = [] }
@backref_fks = Hash.new{ |h, k| h[k] = [] }

env.connection.tables_only.each do |table|
env.connection.tables.each do |table|
if (fks = env.connection.foreign_keys(table)).any?
env.dump.data.has_fks = true
@inline_fks[table] = fks
Expand Down
2 changes: 1 addition & 1 deletion lib/schema_plus/foreign_keys/version.rb
Expand Up @@ -2,6 +2,6 @@

module SchemaPlus
module ForeignKeys
VERSION = "1.0.0"
VERSION = "1.0.1.beta.1"
end
end
3 changes: 3 additions & 0 deletions schema_dev.yml
Expand Up @@ -2,9 +2,12 @@ ruby:
- 2.5
- 2.7
- 3.0
- 3.1
activerecord:
- 5.2
- 6.0
- 6.1
- 7.0
db:
- mysql2
- sqlite3
Expand Down
7 changes: 3 additions & 4 deletions schema_plus_foreign_keys.gemspec
Expand Up @@ -22,13 +22,12 @@ Gem::Specification.new do |gem|

gem.required_ruby_version = ">= 2.5.0"

gem.add_dependency "activerecord", ">= 5.2", "< 6.1"
gem.add_dependency "schema_plus_core", "~> 3.0.0"
gem.add_dependency "schema_plus_compatibility", "~> 1.0.0"
gem.add_dependency "activerecord", ">= 5.2", "< 7.1"
gem.add_dependency "schema_plus_core", "~> 3.1.0.beta.2"
gem.add_dependency "valuable"

gem.add_development_dependency "bundler"
gem.add_development_dependency "rake", "~> 13.0"
gem.add_development_dependency "rspec", "~> 3.0"
gem.add_development_dependency "schema_dev", "~> 4.1"
gem.add_development_dependency "schema_dev", "~> 4.2.beta.1"
end
2 changes: 1 addition & 1 deletion spec/migration_spec.rb
Expand Up @@ -333,7 +333,7 @@ class Comment < ::ActiveRecord::Base ; end
it "should remove a foreign key constraint"+suffix, :sqlite3 => :skip do
Comment.reset_column_information
expect(Comment).to reference(:users, :id).on(:user_id)
migration = Class.new ::ActiveRecord::Migration.latest_version do
migration = Class.new ::ActiveRecord::Migration::Current do
define_method(:change) {
change_table("comments", :bulk => bulk) do |t|
t.references :user, foreign_key: true
Expand Down
4 changes: 2 additions & 2 deletions spec/schema_dumper_spec.rb
Expand Up @@ -7,7 +7,7 @@
before(:each) do
ActiveRecord::Migration.suppress_messages do
ActiveRecord::Schema.define do
connection.tables_only.each do |table| drop_table table, force: :cascade end
connection.tables.each do |table| drop_table table, force: :cascade end

create_table :users, force: true do |t|
t.string :login
Expand Down Expand Up @@ -144,7 +144,7 @@ class ::Comment < ActiveRecord::Base ; end

ActiveRecord::Migration.suppress_messages do
ActiveRecord::Schema.define do
connection.tables_only.each do |table| drop_table table, force: :cascade end
connection.tables.each do |table| drop_table table, force: :cascade end

create_table :grade_systems, force: true do |t|
t.string :name
Expand Down
7 changes: 3 additions & 4 deletions spec/spec_helper.rb
@@ -1,8 +1,7 @@
# frozen_string_literal: true

require 'simplecov'

SimpleCov.start
SimpleCov.start unless SimpleCov.running

$LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
Expand All @@ -24,7 +23,7 @@
begin
example.run
ensure
ActiveRecord::Base.connection.tables_only.each do |table|
ActiveRecord::Base.connection.tables.each do |table|
ActiveRecord::Migration.drop_table table, force: :cascade
end
end
Expand All @@ -50,7 +49,7 @@ def define_schema(config={}, &block)
with_fk_config(config) do
ActiveRecord::Migration.suppress_messages do
ActiveRecord::Schema.define do
connection.tables_only.each do |table|
connection.tables.each do |table|
drop_table table, force: :cascade
end
instance_eval &block
Expand Down

0 comments on commit fe9f7b3

Please sign in to comment.