Closed Xan1912 closed 5 years ago
Hey @Xan1912, Sorry for the late reply, I didn't write the sync method and was hoping that @hammady would respond but seems he hasn't had a chance. So here is my best guess in what's happening.
It seems your table nian
doesn't have an updated_at
column (DateTime) which is needed to use with sync.
So sorry @Xan1912 for not handling this, @anlek is correct, as per the sync documentation, tables need to have an updated_at field for the sync to work. This is the only way sync knows what has changed in your data since the last sync command. This means that you also need to maintain this column by updating it to the current time whenever corresponding rows change.
I have followed the necessary steps to sync the database. But still I am facing this error. Can you please help me out here with a clear description about how the 'sync' command works? Thanks.
meghdut@MS:~$ mongify sync datab.config nian.rb /home/meghdut/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activerecord-3.2.22.2/lib/active_record/connection_adapters/mysql_adapter.rb:308:in'
query': Mysql::Error: Unknown column 't.updated_at' in 'where clause': SELECT t.* FROM nian t, __mongify_sync_helper__ u WHERE t.updated_at > u.last_updated_at AND u.table_name = 'nian' (ActiveRecord::StatementInvalid) from /home/meghdut/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activerecord-3.2.22.2/lib/active_record/connection_adapters/mysql_adapter.rb:308:in
block in exec_without_stmt' from /home/meghdut/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activerecord-3.2.22.2/lib/active_record/connection_adapters/abstract_adapter.rb:280:inblock in log' from /home/meghdut/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-3.2.22.2/lib/active_support/notifications/instrumenter.rb:20:in
instrument' from /home/meghdut/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activerecord-3.2.22.2/lib/active_record/connection_adapters/abstract_adapter.rb:275:inlog' from /home/meghdut/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activerecord-3.2.22.2/lib/active_record/connection_adapters/mysql_adapter.rb:307:in
exec_without_stmt' from /home/meghdut/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activerecord-3.2.22.2/lib/active_record/connection_adapters/mysql_adapter.rb:290:inexec_query' from /home/meghdut/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activerecord-3.2.22.2/lib/active_record/connection_adapters/mysql_adapter.rb:430:in
select' from /home/meghdut/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activerecord-3.2.22.2/lib/active_record/connection_adapters/abstract/database_statements.rb:18:inselect_all' from /home/meghdut/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activerecord-3.2.22.2/lib/active_record/connection_adapters/abstract/query_cache.rb:63:in
select_all' from /home/meghdut/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/mongify-1.2.4/lib/mongify/database/sql_connection.rb:108:inselect_by_query' from /home/meghdut/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/mongify-1.2.4/lib/mongify/translation/sync.rb:61:in
block in sync_data' from /home/meghdut/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/mongify-1.2.4/lib/mongify/translation/sync.rb:58:ineach' from /home/meghdut/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/mongify-1.2.4/lib/mongify/translation/sync.rb:58:in
sync_data' from /home/meghdut/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/mongify-1.2.4/lib/mongify/translation/sync.rb:29:insync' from /home/meghdut/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/mongify-1.2.4/lib/mongify/cli/command/worker.rb:71:in
execute' from /home/meghdut/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/mongify-1.2.4/lib/mongify/cli/application.rb:28:inexecute!' from /home/meghdut/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/mongify-1.2.4/bin/mongify:15:in
<top (required)>' from /home/meghdut/.rbenv/versions/2.3.1/bin/mongify:23:inload' from /home/meghdut/.rbenv/versions/2.3.1/bin/mongify:23:in