0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-11 02:59:07 +08:00
discourse/migrations/core
Gerhard Schlager 3513c77e90 MT: Add reads_table to generate a step's items and max_progress
Most converter steps just read a whole table and map its columns. They each
spell out a `SELECT *` for `items` and a `COUNT(*)` for `max_progress`, plus
`attr_accessor :source_db`, which is the same boilerplate over and over.

This adds `reads_table` to the source role. A step declares the table (and an
optional `where`) and the source fills in both `items` and `max_progress` from
it. The SQL itself is built in the adapter (`select_all`/`count_all`), so the
table name is quoted there and core stays free of SQL. I also moved `source_db`
onto the base source, so steps no longer repeat the accessor.

20 of the 30 Discourse steps are a plain table read and now shrink to a single
`reads_table` line. The other 10 keep their custom `items` (joins, CTEs, window
functions, in-SQL dedup) and just drop the repeated accessor.
2026-06-30 21:06:39 +02:00
..
bin
config MT: Add a TUI progress reporter and use it in the importer too 2026-06-25 17:46:04 +02:00
db MT: Resync schema and coverage after rebase on main 2026-06-29 16:52:41 +02:00
lib MT: Add reads_table to generate a step's items and max_progress 2026-06-30 21:06:39 +02:00
spec MT: Add reads_table to generate a step's items and max_progress 2026-06-30 21:06:39 +02:00
.rspec
Gemfile
migrations-core.gemspec MT: Add a TUI progress reporter and use it in the importer too 2026-06-25 17:46:04 +02:00