activerecord-virgodb-adapter 0.1.7 → 0.1.8

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: d70a70ab0e46de3acd4d283c69e7c385873c7bb9ec817423f62ff09dbc601350
4
- data.tar.gz: 1f7b6259306a3d61f2e3d05fb345373a5d350b2742309804be1d91ac096886a1
3
+ metadata.gz: b21e3613bde955c3741ba92692bb2465036783609e4d11f9540ce0283ea83732
4
+ data.tar.gz: 34b1d14f797d629a6f09c029d422803353df2d86cb8c0682883bbb90d56fde18
5
5
  SHA512:
6
- metadata.gz: 64c5716aa1f9d1ea110aacd562ad131acb5d8d76bbd4e8d0ed459a2191530d7b27c6c1f924b59a70840defed6f285c668e6fc9a56f97b134719bd2033ed42b6f
7
- data.tar.gz: 9f2de20a524c86e2bafc0a43b6f49b8d86bdf127a54b8a5276972f75b10e937c5c7fe3b89b88172eaca32b4aaee09aa0aa52a34f947c614dc3926c3d1878f82e
6
+ metadata.gz: cbafb03b4df28cc059ed39deffd6504916232cb545b4ae2c7bce66e55121837e90cb3a76c8ecc6fd074277665abd6c438042ecce57530a5960b0fc6391a2d314
7
+ data.tar.gz: 79aae8c9a8cbcc419ac83295f371d24122cfddf291d5974c473d23cbafa512b3a177109197b86f090c349af594eb1533d47bea3e2bd84e7a2a28fe835d08c02a
@@ -134,32 +134,45 @@ module ActiveRecord
134
134
  # history here isn't a correctness requirement. It also isn't a
135
135
  # readability win: each version's `columns` re-lists every column from
136
136
  # scratch, so N migrations means N near-duplicate JSON blobs, longer
137
- # every time. The version count/dates are still worth one line for
138
- # orientation -- the full column list per version isn't; the
139
- # migration files themselves (db/migrate_virgodb_*/*.rb, timestamped,
140
- # under git blame) are already the authoritative "what changed when"
141
- # record. `register_schema_version`'s additive-only check is
142
- # unaffected: it only ever compares a new migration's proposed columns
143
- # against the CURRENT version, which is exactly what's still dumped.
137
+ # every time. The migration files themselves (db/migrate_virgodb_*/*.rb,
138
+ # timestamped, under git blame) are already the authoritative "what
139
+ # changed when" record. `register_schema_version`'s additive-only check
140
+ # is unaffected: it only ever compares a new migration's proposed
141
+ # columns against the CURRENT version, which is exactly what's still
142
+ # dumped.
143
+ #
144
+ # `applied_at` is dumped as a fixed `0`, and no per-version history
145
+ # comment is written -- both used to carry real wall-clock data
146
+ # (`Time.now.to_i` at migration time), which made this file diff on
147
+ # every clean rebuild (`db:drop` + `db:migrate`) even when the actual
148
+ # schema hadn't changed at all. Confirmed nothing reads either back:
149
+ # `current_schema_version` only ever selects `version, columns` (see
150
+ # above), and this adapter's own `assert_additive!`/
151
+ # `record_added_column!` only ever read `columns` too. The live
152
+ # manifest's real `schema_versions` table is untouched by this --
153
+ # `applied_at` still gets a real timestamp there at migration time,
154
+ # useful for a human inspecting the live table directly. This only
155
+ # changes what a fresh `structure_load` seeds into a NEW database,
156
+ # where a wall-clock value was never reproducible enough to belong in
157
+ # a checked-in file meant to represent "current schema shape," not
158
+ # "when someone last regenerated this file."
144
159
  def dump_schema_versions!(filename)
145
160
  return unless connection.data_source_exists?("schema_versions")
146
161
 
147
- rows = connection.select_all("SELECT id, table_name, version, columns, applied_at FROM schema_versions ORDER BY table_name, version")
162
+ rows = connection.select_all("SELECT id, table_name, version, columns FROM schema_versions ORDER BY table_name, version")
148
163
  return if rows.to_a.empty?
149
164
 
150
165
  File.open(filename, "a") do |f|
151
166
  f.puts
152
167
  rows.to_a.group_by { |r| r["table_name"] }.each do |table_name, versions|
153
168
  latest = versions.max_by { |r| r["version"] }
154
- history = versions.map { |r| "v#{r['version']} (#{Time.at(r['applied_at'].to_i).utc.strftime('%Y-%m-%d')})" }.join(", ")
155
169
 
156
- f.puts "-- #{table_name} schema history: #{history} -- only the current version is dumped below; see db/migrate_virgodb_*/ for the rest"
157
170
  pretty_columns = JSON.pretty_generate(JSON.parse(latest["columns"]))
158
171
  f.puts(
159
172
  "INSERT INTO \"schema_versions\" (id, table_name, version, columns, applied_at) VALUES (\n" \
160
173
  " #{latest['id']}, #{connection.quote(table_name)}, #{latest['version']},\n" \
161
174
  " #{connection.quote(pretty_columns)},\n" \
162
- " #{latest['applied_at']}\n" \
175
+ " 0\n" \
163
176
  ");"
164
177
  )
165
178
  f.puts
@@ -199,7 +212,7 @@ module ActiveRecord
199
212
  # `SQLiteDatabaseTasks#structure_dump`'s `ignore_tables`-triggered
200
213
  # fallback (used whenever `ActiveRecord::SchemaDumper.ignore_tables` is
201
214
  # non-empty, e.g. excluding tables owned by a separate replication/
202
- # backup mechanism -- exactly hintpot's own litestream initializer)
215
+ # backup mechanism -- exactly a host app's own Litestream initializer)
203
216
  # runs `SELECT sql || ';' FROM sqlite_master WHERE tbl_name NOT IN
204
217
  # (...) ORDER BY tbl_name, type DESC, name` through the `sqlite3` CLI.
205
218
  # Any table with a non-INTEGER (so non-rowid-alias) PRIMARY KEY --
@@ -271,8 +284,8 @@ module ActiveRecord
271
284
 
272
285
  # Matches `db/clickhouse_structure.sql` and `db/schema.rb`'s own
273
286
  # convention (both, unprompted, separate every top-level table
274
- # definition with a blank line -- confirmed directly against
275
- # hintpot's real dumps of each, not assumed) rather than inventing a
287
+ # definition with a blank line -- confirmed directly against a real
288
+ # host app's dumps of each, not assumed) rather than inventing a
276
289
  # new one here. Only CREATE TABLE gets a leading blank line, not
277
290
  # CREATE INDEX/CREATE UNIQUE INDEX -- those stay glued directly under
278
291
  # their own table, same as clickhouse_structure.sql has no equivalent
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-virgodb-adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - virgodb