schema_ferry 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a1d8f26a5f4ae7a05dde0ab5385b893c2271d95127b74363e9fe9f55ed513b86
4
- data.tar.gz: b1db489a98150c49b6446ddaa79d15cff8a4f4f8eb68759384013d73b9b02fbb
3
+ metadata.gz: ffeee05f1fb01ebb90d2a75df3077d46788714b4aa192de62f7f9b4f62c1824c
4
+ data.tar.gz: 4977e0f544613fd09d6d61674407b281463e2fca75770d8b21aea0e60f94de44
5
5
  SHA512:
6
- metadata.gz: a4f9341de8e149c2e281c6a278a55d178bdf00f56a18d8362c23266d37e4d4ef54ae36daa97399e3de7db46b4e7ff3552bc98215f564b1cc0698c4db5daa5cb0
7
- data.tar.gz: cdf15361234635907e9aacb90075ed6edb6ddc681360650ad3fc7a38d5a8c75057492ec84405bd884d639397addc6abc47369297181c5ae426293634ed54e043
6
+ metadata.gz: 9fc86363dac3a3bcb9e4bbf852ef3a5f5ea7113dbf6c9722cf0741b666b49da056b4334d866fec935e4255aff0ae72ffa943d1b028f966edfc5caa433a04f6ca
7
+ data.tar.gz: a6a95a90bfd5ddbcbfcc4bc25de2ab3036c68f5d9d272478bf74a1c0980ca8fb19bf1c01425db83cbc6b0ed87adac02a64ff0977b91d12d5cbc30e57fda909ae
data/CHANGELOG.md CHANGED
@@ -7,6 +7,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.1.3] - 2026-07-06
11
+
12
+ ### Fixed
13
+
14
+ - The 0.1.2 fix only covered the two reported cases, not the underlying pattern: any type/option combination that PostgreSQL can't actually reproduce back to ActiveRecord causes `apply!` to re-run `change_column` forever, because ridgepole compares the declaration against a state it can never match.
15
+ - `DOUBLE` columns (`:float`) are read with `limit: 53` (the type's internal bit width), but a PostgreSQL column never reports a limit back. `limit` is no longer emitted for `:float` columns.
16
+ - Plain `DECIMAL` columns with a default (not just ones bumped from `BIGINT UNSIGNED`) now render their default as a string, matching the form ActiveRecord's schema dumper uses for decimal defaults — the same fix from 0.1.2, generalized to `TypeMapper` so it applies to every decimal column instead of only the unsigned-bigint conversion path.
17
+
18
+ ## [0.1.2] - 2026-07-06
19
+
20
+ ### Fixed
21
+
22
+ - `map_type :datetime, to: :timestamptz` no longer produces a schema that never converges: ActiveRecord's PostgreSQL adapter silently ignores a `precision:` option on `:timestamptz` columns (unlike `:datetime`/`:timestamp`/`:time`, where it's honored), so declaring one caused `apply!` to re-run `change_column` on every single run. `precision` is no longer emitted for `:timestamptz` columns.
23
+ - `BIGINT UNSIGNED` columns with a default value (e.g. `DEFAULT 0`) no longer cause `apply!` to re-run `change_column` on every run after the initial `apply!`. The default is now converted to match the string form ActiveRecord's schema dumper uses for decimal defaults, so it matches ridgepole's exported state instead of diffing against it forever.
24
+
10
25
  ## [0.1.1] - 2026-07-06
11
26
 
12
27
  ### Fixed
@@ -3,15 +3,22 @@
3
3
  module SchemaFerry
4
4
  module Converter
5
5
  class TypeMapper
6
- # PG has no limit concept for text/binary/bigint; drop the MySQL-derived
7
- # limits.
8
- LIMIT_STRIPPED_TYPES = %i[text binary bigint].freeze
6
+ # PG has no limit concept for text/binary/bigint/float; drop the
7
+ # MySQL-derived limits (float's limit: 53 is DOUBLE's internal bit
8
+ # width, not something AR ever reads back from a PG column).
9
+ LIMIT_STRIPPED_TYPES = %i[text binary bigint float].freeze
9
10
 
10
11
  # PG's default timestamp precision is 6. Spelling it out makes ridgepole
11
12
  # see a diff against the PG export (which omits it) on every run.
12
- DEFAULT_PRECISION_TYPES = %i[datetime timestamptz time].freeze
13
+ DEFAULT_PRECISION_TYPES = %i[datetime time].freeze
13
14
  PG_DEFAULT_PRECISION = 6
14
15
 
16
+ # ActiveRecord's PostgreSQL adapter never honors a precision option on
17
+ # :timestamptz (only :datetime/:timestamp/:time do — see
18
+ # ActiveRecord::ConnectionAdapters::SchemaStatements#type_to_sql).
19
+ # Declaring one is always a lie, so it must never be emitted.
20
+ NO_PRECISION_TYPES = %i[timestamptz].freeze
21
+
15
22
  DEFAULTS = {
16
23
  json: :jsonb
17
24
  }.freeze
@@ -37,8 +44,15 @@ module SchemaFerry
37
44
  pg_type, adjusted = normalize_integer(adjusted) if pg_type == :integer
38
45
  adjusted.delete(:limit) if LIMIT_STRIPPED_TYPES.include?(pg_type)
39
46
  strip_default_precision(pg_type, adjusted)
40
- # PG numeric(20) equals numeric(20,0) and is exported without scale.
41
- adjusted[:scale] = nil if pg_type == :decimal && adjusted[:scale]&.zero?
47
+ if pg_type == :decimal
48
+ # PG numeric(20) equals numeric(20,0) and is exported without scale.
49
+ adjusted[:scale] = nil if adjusted[:scale]&.zero?
50
+ # AR's schema dumper renders decimal defaults as a string (e.g.
51
+ # `default: "0"`), not a numeric literal. ridgepole compares against
52
+ # that dumped form, so a BigDecimal/Integer default never matches
53
+ # and gets re-applied on every run.
54
+ adjusted[:default] = adjusted[:default]&.to_s
55
+ end
42
56
 
43
57
  [pg_type, adjusted]
44
58
  end
@@ -58,6 +72,7 @@ module SchemaFerry
58
72
  end
59
73
 
60
74
  def strip_default_precision(pg_type, options)
75
+ options[:precision] = nil if NO_PRECISION_TYPES.include?(pg_type)
61
76
  return unless DEFAULT_PRECISION_TYPES.include?(pg_type)
62
77
 
63
78
  options[:precision] = nil if options[:precision] == PG_DEFAULT_PRECISION
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SchemaFerry
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.3"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: schema_ferry
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - kyuuri1791