activerecord-virgodb-adapter 0.1.7 → 0.1.9

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: c9adcef53b08377de04eaa8a3efb42a9ef26af8c9d21d354417a9431374ffb5b
4
+ data.tar.gz: '089277465d82f97c0075bb1641c46bd37e02a3c44d0e3f627d02962a473bfcfd'
5
5
  SHA512:
6
- metadata.gz: 64c5716aa1f9d1ea110aacd562ad131acb5d8d76bbd4e8d0ed459a2191530d7b27c6c1f924b59a70840defed6f285c668e6fc9a56f97b134719bd2033ed42b6f
7
- data.tar.gz: 9f2de20a524c86e2bafc0a43b6f49b8d86bdf127a54b8a5276972f75b10e937c5c7fe3b89b88172eaca32b4aaee09aa0aa52a34f947c614dc3926c3d1878f82e
6
+ metadata.gz: f7c81193bd344ef5e4120c7147e4374d5421fb17e129937b829bb6f01fcc59ec8e1734916f7c85e2a07ff3b66687a09de0cc361a6489bc85459fb4e086083894
7
+ data.tar.gz: 5df55c10f41ff7fd8264e561e470966fa3b9aadf8e7691304f6ad0d8336fb0939780782df4c03a33b68369f691a357ca70a146261f3f812c891c7c5ada66a2e9
@@ -458,8 +458,8 @@ module ActiveRecord
458
458
  next_version = (select_value("SELECT MAX(version) FROM schema_versions WHERE table_name = #{quote(table_name)}") || 0).to_i + 1
459
459
 
460
460
  execute(<<~SQL)
461
- INSERT INTO schema_versions (table_name, version, columns, applied_at)
462
- VALUES (#{quote(table_name)}, #{next_version}, #{quote(cols.to_json)}, #{Time.now.to_i})
461
+ INSERT INTO schema_versions (table_name, version, columns)
462
+ VALUES (#{quote(table_name)}, #{next_version}, #{quote(cols.to_json)})
463
463
  SQL
464
464
  end
465
465
 
@@ -471,14 +471,21 @@ module ActiveRecord
471
471
  # in manifest/src/lib.rs for why (breaks a real structure_dump/
472
472
  # structure_load round trip the moment any host app's
473
473
  # ActiveRecord::SchemaDumper.ignore_tables is non-empty).
474
+ #
475
+ # No `applied_at` column (removed -- nothing ever read it back, see
476
+ # manifest/src/lib.rs's matching comment on `register_schema_version`).
477
+ # Breaking format change, no in-place migration: `IF NOT EXISTS` is a
478
+ # no-op against a manifest that already has the old `applied_at NOT
479
+ # NULL` shape, so `insert_schema_version!` above would fail against
480
+ # one -- deliberate, pre-production, existing manifests get dropped
481
+ # and recreated rather than migrated.
474
482
  def ensure_schema_versions_table!
475
483
  execute(<<~SQL)
476
484
  CREATE TABLE IF NOT EXISTS schema_versions (
477
485
  id INTEGER PRIMARY KEY,
478
486
  table_name TEXT NOT NULL,
479
487
  version INTEGER NOT NULL,
480
- columns TEXT NOT NULL,
481
- applied_at INTEGER NOT NULL
488
+ columns TEXT NOT NULL
482
489
  )
483
490
  SQL
484
491
  end
@@ -134,32 +134,37 @@ 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
+ # `schema_versions` has no `applied_at` column as of this adapter
145
+ # version (removed from the manifest's own schema, see
146
+ # manifest/src/lib.rs's matching comment on `register_schema_version`
147
+ # -- nothing ever read it back). It used to carry real wall-clock data
148
+ # (`Time.now.to_i` at migration time), which made this file diff on
149
+ # every clean rebuild (`db:drop` + `db:migrate`) even when the actual
150
+ # schema hadn't changed at all -- that's gone now along with the
151
+ # column, not just papered over here.
144
152
  def dump_schema_versions!(filename)
145
153
  return unless connection.data_source_exists?("schema_versions")
146
154
 
147
- rows = connection.select_all("SELECT id, table_name, version, columns, applied_at FROM schema_versions ORDER BY table_name, version")
155
+ rows = connection.select_all("SELECT id, table_name, version, columns FROM schema_versions ORDER BY table_name, version")
148
156
  return if rows.to_a.empty?
149
157
 
150
158
  File.open(filename, "a") do |f|
151
159
  f.puts
152
160
  rows.to_a.group_by { |r| r["table_name"] }.each do |table_name, versions|
153
161
  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
162
 
156
- f.puts "-- #{table_name} schema history: #{history} -- only the current version is dumped below; see db/migrate_virgodb_*/ for the rest"
157
163
  pretty_columns = JSON.pretty_generate(JSON.parse(latest["columns"]))
158
164
  f.puts(
159
- "INSERT INTO \"schema_versions\" (id, table_name, version, columns, applied_at) VALUES (\n" \
165
+ "INSERT INTO \"schema_versions\" (id, table_name, version, columns) VALUES (\n" \
160
166
  " #{latest['id']}, #{connection.quote(table_name)}, #{latest['version']},\n" \
161
- " #{connection.quote(pretty_columns)},\n" \
162
- " #{latest['applied_at']}\n" \
167
+ " #{connection.quote(pretty_columns)}\n" \
163
168
  ");"
164
169
  )
165
170
  f.puts
@@ -199,7 +204,7 @@ module ActiveRecord
199
204
  # `SQLiteDatabaseTasks#structure_dump`'s `ignore_tables`-triggered
200
205
  # fallback (used whenever `ActiveRecord::SchemaDumper.ignore_tables` is
201
206
  # non-empty, e.g. excluding tables owned by a separate replication/
202
- # backup mechanism -- exactly hintpot's own litestream initializer)
207
+ # backup mechanism -- exactly a host app's own Litestream initializer)
203
208
  # runs `SELECT sql || ';' FROM sqlite_master WHERE tbl_name NOT IN
204
209
  # (...) ORDER BY tbl_name, type DESC, name` through the `sqlite3` CLI.
205
210
  # Any table with a non-INTEGER (so non-rowid-alias) PRIMARY KEY --
@@ -271,8 +276,8 @@ module ActiveRecord
271
276
 
272
277
  # Matches `db/clickhouse_structure.sql` and `db/schema.rb`'s own
273
278
  # 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
279
+ # definition with a blank line -- confirmed directly against a real
280
+ # host app's dumps of each, not assumed) rather than inventing a
276
281
  # new one here. Only CREATE TABLE gets a leading blank line, not
277
282
  # CREATE INDEX/CREATE UNIQUE INDEX -- those stay glued directly under
278
283
  # 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.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - virgodb