-
Notifications
You must be signed in to change notification settings - Fork 21
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
table with sequence id from another table : the generated chronomodel_XYZ_insert() is broken #91
Comments
This is expected AR/Postgres behaviour, because the sequence used in
ChronoModel uses the [5] pry(main)> ActiveRecord::Base.connection.serial_sequence 'temporal.table_a', 'id'
=> "temporal.table_a_id_seq"
[6] pry(main)> ActiveRecord::Base.connection.serial_sequence 'temporal.table_b', 'id'
=> nil The AR method internally calls Each sequence has an owner column and
produces in Ruby: [19] pry(main)> adapter.serial_sequence 'temporal.table_a', 'id'
=> nil However, I found that AR has a custom shared sequence [31] pry(main)> adapter.pk_and_sequence_for('temporal.table_a').last.to_s
=> "temporal.foobar"
[32] pry(main)> adapter.pk_and_sequence_for('temporal.table_b').last.to_s
=> "temporal.foobar" sequence created as a consequence of a serial column [33] pry(main)> adapter.pk_and_sequence_for('temporal.table_a').last.to_s
=> "temporal.table_a_id_seq"
[35] pry(main)> adapter.pk_and_sequence_for('temporal.table_b').last.to_s
=> "temporal.table_a_id_seq" So I am now giving it a try. |
Thanks a lot, |
Hi,
first i use ruby 2.3 / rails 4.2 with chronomodel 0.9.1
and postgres 9.4.12
when a change a table (with an id sequence of anothe table) to a chronomodel table using rails migration, the generated chronomodel_XYZ_insert() is broken
Here a table with is own id sequence (no pb on this table)
I want to apply chronomoel to table_a, so a do migration like this :
here the tables informations :
now i have a second table 'table_b' which must have the same sequence than 'table_a'
I want to apply chronomodel to table_b, so a do migration like this :
here the tables informations :
in summary :
Table "temporal.table_a"
Table "history.table_a"
chronomodel_table_a_insert()
Table "temporal.table_b"
Table "history.table_b"
chronomodel_table_b_insert()
==>
as you can see the nextval in the chronomodel_table_b_insert is broken because there is no sequence
this problem only occured when i use an id sequence uses by other table ( same things if table_a is or is not a chronomodel table)
I know i use an old version of chronomodel ... but can you take a look on this.
maybe i forgot an option in migration, or maybe it's a bug ...
thanks a lot .
Thomas
The text was updated successfully, but these errors were encountered: