Class: ActiveRecord::Tasks::VirgodbDatabaseTasks
- Inherits:
-
SQLiteDatabaseTasks
- Object
- SQLiteDatabaseTasks
- ActiveRecord::Tasks::VirgodbDatabaseTasks
- Defined in:
- lib/activerecord-virgodb-adapter.rb
Overview
ActiveRecord::Tasks::SQLiteDatabaseTasks#structure_dump just shells
out to the real sqlite3 CLI (.schema --nosys, or a raw SELECT sql FROM sqlite_master when a host app has any
ActiveRecord::SchemaDumper.ignore_tables configured -- e.g. excluding
tables owned by a separate replication/backup mechanism) against the
configured database file --
DDL only. ActiveRecord::Tasks::DatabaseTasks.dump_schema then
special-cases exactly one table on top of that: if schema_migrations
exists, it appends that table's real row data (connection .dump_schema_versions) to the same dump file, because Rails' own
migration bookkeeping needs those rows to survive a db:schema:load/
structure_load, not just the table shape.
schema_versions (this adapter's own bookkeeping table, plural,
distinct from Rails' singular schema_migrations) needs exactly the
same treatment and doesn't get it for free: it holds real data (the
versioned column list compact::schema_from_columns on the Rust side
depends on), not just structure, and Rails has no way to know that a
table it didn't create needs the same row-preserving special case.
Confirmed empirically: without this, a fresh database prepared via
structure_load (which Rails does automatically whenever a db:migrate
invocation for a later environment/connection finds an existing,
version-matching dump already on disk from an earlier one -- not
something this adapter can opt out of) ends up with the real
host-app table but an EMPTY schema_versions, so
Manifest::current_schema_version() on the Rust side returns None
even though the SQLite table itself is correct.
Class Attribute Summary collapse
-
.table_layout_provider ⇒ Object
Optional host-app hook:
->(sql_table_name) { {sort_by:, key_column:, partition_column:} or nil }.
Instance Method Summary collapse
Class Attribute Details
.table_layout_provider ⇒ Object
Optional host-app hook: ->(sql_table_name) { {sort_by:, key_column:, partition_column:} or nil }. Purely a documentation comment written
above CREATE TABLE at dump time -- nothing on the Rust or Ruby side
ever reads it back. This adapter gem stays host-app-agnostic (see
the class doc comment above: "lets any Rails app..."), so it can't
hardcode any one host app's sort_by/key_column config (that's
app/services/virgodb/registry.rb's job, which already has this
exact data for real -- passed to Virgodb.start_maintenance on every
boot). A host app that wants it surfaced sets this once, e.g. in an
initializer; left nil, structure_dump behaves exactly as before.
257 258 259 |
# File 'lib/activerecord-virgodb-adapter.rb', line 257 def table_layout_provider @table_layout_provider end |
Instance Method Details
#structure_dump(filename, extra_flags) ⇒ Object
260 261 262 263 264 265 |
# File 'lib/activerecord-virgodb-adapter.rb', line 260 def structure_dump(filename, extra_flags) super reformat_create_table_statements!(filename) annotate_physical_layout!(filename) dump_schema_versions!(filename) end |