It’s a bit safer having Rails do it than modifying the database yourself, but you can do it if you want. Note that you have to touch at least the user and user_emails tables, and see that the user_ids match.
Have a look at discourse/db/fixtures/009_users.rb at main · discourse/discourse · GitHub and then create a plugin that similarly adds a fixture (maybe ./discourse-salesforce/db/fixtures/001_groups.rb).
You could also use an import script as an example.