mirror of
https://github.com/internetee/registry.git
synced 2025-07-20 09:46:09 +02:00
Fix relations sql
This commit is contained in:
parent
ecee4fa64c
commit
7707f5ff8e
1 changed files with 8 additions and 1 deletions
|
@ -148,7 +148,14 @@ namespace :import do
|
|||
Address.import address_columns, addresses, validate: false
|
||||
|
||||
puts '-----> Updating relations...'
|
||||
ActiveRecord::Base.connection.execute('UPDATE addresses SET contact_id = legacy_contact_id WHERE legacy_contact_id IS NOT NULL AND contact_id IS NULL')
|
||||
ActiveRecord::Base.connection.execute(
|
||||
"UPDATE addresses "\
|
||||
"SET contact_id = contacts.id "\
|
||||
"FROM contacts "\
|
||||
"WHERE contacts.legacy_id = legacy_contact_id "\
|
||||
"AND legacy_contact_id IS NOT NULL "\
|
||||
"AND contact_id IS NULL"
|
||||
)
|
||||
puts "-----> Imported #{count} new contacts in #{(Time.now.to_f - start).round(2)} seconds"
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue