First of all, open a rails console
bundle exec rails c
And then:
table = Table.new
table.user_id = # whatever id
table.name = # name of the existing table
table.table_id = # relation's object identifier
table.migrate_existing_table = # name of the existing table
table.save
See User#link_created_tables for reference: https://github.com/CartoDB/cartodb20/blob/develop/app/models/user.rb#L411