Problem
The manual-control API creates a staging table, inserts, transfers, drops. If a user wants to run several imports back-to-back in the same session (same connection, same schema), they either drop+recreate (slow) or live with stale data.
Proposal
session = StagingTable::Session.new(User)
session.create_table
batches.each do |batch|
session.truncate # O(1), keeps table structure/indexes
session.insert(batch)
session.transfer
end
session.drop_table
Acceptance criteria
truncate runs TRUNCATE <staging_table> (PG/MySQL) or DELETE FROM ... (SQLite)
- Preserves any indexes created via
after_insert_indexes
- Instrumented with
staging_table.truncate
- Tested against all three adapters
Problem
The manual-control API creates a staging table, inserts, transfers, drops. If a user wants to run several imports back-to-back in the same session (same connection, same schema), they either drop+recreate (slow) or live with stale data.
Proposal
Acceptance criteria
truncaterunsTRUNCATE <staging_table>(PG/MySQL) orDELETE FROM ...(SQLite)after_insert_indexesstaging_table.truncate