Skip to content

feat: allow custom version table name per model#77

Merged
waymondo merged 13 commits into
waymondo:mainfrom
buntine:main
Feb 8, 2026
Merged

feat: allow custom version table name per model#77
waymondo merged 13 commits into
waymondo:mainfrom
buntine:main

Conversation

@buntine

@buntine buntine commented Jan 5, 2026

Copy link
Copy Markdown
Contributor

Here is a proposed small change to allow specifying a custom version table name from the source model.

The default is <source_table>_versions, but we have a particular situation where this generated name is not available so I'd like to be able to specify a custom versions table name.

It's done like so:

class Post < ActiveRecord::Base
  include Hoardable::Model
  self.version_table_name = "post_histories" # or whatever you want.
end

Putting this directly into hoardable_config is a bit tricky because the current CONFIG_KEYS are all presumed to be booleans so this change would break that pattern. But considering this is a fairly minor change and likely pretty obscure, I am not sure changing the behaviour of hoardable_config is warranted?

Open to ideas, though!


Note that I have added a fix in this PR also.

The contextual_event_uuid was potentially getting leaked into the surrounding scope because it was being copied onto the hoardable_event_uuid aswell.

So:

ActiveRecord::Base.transaction do
  Hoardable.with(event_uuid: "blah") do
    MyModel.first.update(name: "cool")
  end
  
  MyModel.first.update(name: "not cool") # event_uuid is still "blah" because it was copied to storage that is not cleared until the transaction is committed
end

We now ensure to only return the contextual_event_uuid if we have it. It will be blown away when the with block is done.

@waymondo waymondo left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works for me. i'll see if i can get an autopublish to rubygems flow working prior to merging this, so i don't need to make sure i'm on the right machine to cut new builds to the registry

super
dump_inherited_tables(stream)
empty_line(stream)
stream.puts

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the tldr on this change?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh - the Ruby 3.3 build checks were failing because Rails 8 has removed the empty_line method. Under the hood it was just doing a puts anyway, so this will give us the same effect.

@waymondo

Copy link
Copy Markdown
Owner

hey sorry this slipped my mind. i will try to get the auto publishing github action workflow done this weekend

@waymondo

Copy link
Copy Markdown
Owner

sorry for the delay on this. i got the autopublish workflow setup, so feel free to bump the version here and the discard the main workflow changes and we can get this merged in

@buntine

buntine commented Jan 29, 2026

Copy link
Copy Markdown
Contributor Author

Ok thanks @waymondo . I have got the PR ready again now.

Note that I have added a fix in here also.

The contextual_event_uuid was potentially getting leaked into the surrounding scope because it was being copied onto the hoardable_event_uuid aswell.

So:

ActiveRecord::Base.transaction do
  Hoardable.with(event_uuid: "blah") do
    MyModel.first.update(name: "cool")
  end
  
  MyModel.first.update(name: "not cool") # event_uuid is still "blah" because it was copied to storage that is not cleared until the transaction is committed
end

@waymondo waymondo merged commit 05063b7 into waymondo:main Feb 8, 2026
9 checks passed
@waymondo

waymondo commented Feb 8, 2026

Copy link
Copy Markdown
Owner

thanks and sorry again i missed the GH notification on your update. work notifications have been extra noisy the last couple weeks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants