-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle id sequences with care #41
Comments
hey, @volkanunsal. Long time no PR 😂. We missed you! This is an interesting idea. At the same time, I think this is something we could try to squeeze in the postgres adapter. Wanna take a stab at it? |
@nettofarah Ha, ok, I'll give it a try. |
This is a feature I would also find very useful |
Yeah, I was thinking about this today. We could add an What do you guys think? |
Depends on if you want to bake this into the default I'm already doing something similar:
|
You can see how we handle this in Brillo (a Polo wrapper with some extra conventions) here |
@bessey maybe we can join forces and try to bring this feature over to Polo? |
Indeed, this is one of the parts of Brillo that would probably fit better in Polo. It doesn't seem like the API would be affected at all either, since you already have a notion of DB specific adapters in Polo. Potentially we'd just need something like https://github.com/IFTTT/polo/blob/master/lib/polo/sql_translator.rb#L23 def to_sql
case @configuration.on_duplicate_strategy
when :ignore
@adapter.ignore_transform(inserts, records)
when :override
@adapter.on_duplicate_key_update(inserts, records)
else inserts
-- end
++ end + @adapter.table_footer(record.class.arel_table)
end |
niice! I like that. if @adapter.respond_to?(:table_footer)
...
end |
I realized that after restoring the dump file generated by Polo, I still had to reset the id sequences postgres uses to determine the next id for a new record. This entails looking up the highest id number in the imported rows, and running the following command for every table:
It would be great if Polo did this automatically, though.
The text was updated successfully, but these errors were encountered: