declare_schema 2.3.0 → 2.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 31dd49e36793094f670d30211da95c08739c4f0c65d11ef1824ab0cacff6508a
4
- data.tar.gz: 0f74f11ad7d6a6b6631dbf695cadcae1d59554ba956306ddda0cd26eee1316c4
3
+ metadata.gz: 32cd73e09d5530729bfef42e4277d229d3688c826a8f8c28575175508fe023ee
4
+ data.tar.gz: 8ce537e1883effbb466242547580c2de3db9ca87064b1ae6a778a3422a3e5f61
5
5
  SHA512:
6
- metadata.gz: 73cec99029586a2e9250848013a86548a14fb64eb46d2f2aecc6c5ed4d1679de8d264e06fde1db9640293ee7e2705d13dfd770c62aecb1f7ab089ca8c805d213
7
- data.tar.gz: bc61c8db52f1890398dfd663c0e7f0d76441fc1d1713f89d095a2cb40bed654ae14a2dfd40a007013cc762f8ae397368e1a89d210e5b9e853953db595ec9ec1d
6
+ metadata.gz: 51a55ba1f327ba291d5b0efece8fa168520ebfd91cd984dad9a4a36cb6b9abfa03379563ff170969124d31e09fd908e2de29c3cb0f9ae8ee4fa840a11c0d3e03
7
+ data.tar.gz: f869a73076a408d5b229d125f59d64af06fc7d1908f6e139fd1a032559a9f6e9476ec3bef93bab43190e264f1f05e35e310c390c14eb990b541ee7944c7d5612
data/CHANGELOG.md CHANGED
@@ -4,6 +4,11 @@ Inspired by [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
4
4
 
5
5
  Note: this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [2.3.1] - Unreleased
8
+ ### Fixed
9
+ - Fixed bug where a new model with `belongs_to :owner, polymorphic: true` would cause
10
+ a "Mysql2::Error: Table '<new table>' doesn't exist:" exception when generating a migration.
11
+
7
12
  ## [2.3.0] - 2024-10-31
8
13
  ### Updated
9
14
  - Updated the `current_adapter` method to use `connection_db_config` for Rails 6.1 and higher, while retaining `connection_config` for earlier versions
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- declare_schema (2.3.0)
4
+ declare_schema (2.3.1)
5
5
  rails (>= 6.0)
6
6
 
7
7
  GEM
@@ -240,7 +240,7 @@ module DeclareSchema
240
240
 
241
241
  def _infer_fk_limit(foreign_key_column, reflection)
242
242
  if reflection.options[:polymorphic]
243
- if (foreign_key_column = columns_hash[foreign_key_column.to_s]) && foreign_key_column.type == :integer
243
+ if (foreign_key_column = _column(foreign_key_column)) && foreign_key_column.type == :integer
244
244
  foreign_key_column.limit
245
245
  end
246
246
  else
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DeclareSchema
4
- VERSION = "2.3.0"
4
+ VERSION = "2.3.1"
5
5
  end
@@ -68,7 +68,7 @@ module DeclareSchema
68
68
  final_migration_name =
69
69
  name.presence ||
70
70
  if !options[:default_name]
71
- choose("\nMigration filename (spaces will be converted to _) [#{default_migration_name}]:", /^[a-z0-9_ ]*$/,
71
+ choose("Migration filename (spaces will be converted to _) [#{default_migration_name}]:", /^[a-z0-9_ ]*$/,
72
72
  default_migration_name).strip.gsub(' ', '_').presence
73
73
  end ||
74
74
  default_migration_name
@@ -1305,6 +1305,7 @@ RSpec.describe 'DeclareSchema Migration Generator' do
1305
1305
  belongs_to :id_default
1306
1306
  belongs_to :id4
1307
1307
  belongs_to :id8
1308
+ belongs_to :owner, polymorphic: true
1308
1309
  end
1309
1310
  end
1310
1311
 
@@ -1332,20 +1333,24 @@ RSpec.describe 'DeclareSchema Migration Generator' do
1332
1333
  it 'infers the correct FK type from the create_table id: type' do
1333
1334
  up = Generators::DeclareSchema::Migration::Migrator.run.first
1334
1335
 
1335
- create_fks = up.split("\n").grep(/t\.integer /).map { |command| command.gsub(', null: false', '').gsub(/^ +/, '') }
1336
+ create_fks = up.split("\n").grep(/t\.integer|string /).map { |command| command.gsub(', null: false', '').gsub(/^ +/, '') }
1336
1337
  if current_adapter == 'sqlite3'
1337
1338
  create_fks.map! { |command| command.gsub(/limit: [a-z0-9]+/, 'limit: X') }
1338
1339
  expect(create_fks).to eq([
1339
1340
  't.integer :id_default_id, limit: X',
1340
1341
  't.integer :id4_id, limit: X',
1341
- 't.integer :id8_id, limit: X'
1342
- ]), up
1342
+ 't.integer :id8_id, limit: X',
1343
+ 't.integer :owner_id, limit: X',
1344
+ 't.string :owner_type, limit: X'
1345
+ ])
1343
1346
  else
1344
1347
  expect(create_fks).to eq([
1345
1348
  't.integer :id_default_id, limit: 8',
1346
1349
  't.integer :id4_id, limit: 4',
1347
- 't.integer :id8_id, limit: 8'
1348
- ]), up
1350
+ 't.integer :id8_id, limit: 8',
1351
+ 't.integer :owner_id, limit: 8',
1352
+ "t.string :owner_type, limit: 255#{charset_and_collation}"
1353
+ ])
1349
1354
  end
1350
1355
  end
1351
1356
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: declare_schema
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Invoca Development adapted from hobo_fields by Tom Locke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-31 00:00:00.000000000 Z
11
+ date: 2024-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails