mirror of
https://github.com/discourse/discourse.git
synced 2026-08-11 02:59:07 +08:00
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. |
||
|---|---|---|
| .. | ||
| bin | ||
| config | ||
| db | ||
| lib | ||
| spec | ||
| .rspec | ||
| Gemfile | ||
| migrations-core.gemspec | ||