How to copy tables from one database

How to copy tables from one database to another in Adonis,I whant to connect two database and copy tables from one database to another

Easiest is to do it in some migration file.

Create new migration that deals only with connecting to one DB, taking all data and then planting it into other DB.

It depends tho are you getting in writes while this migration runs. Then it’s a lot harder topic.
Some is in here:

I think Gitlab also had quite interesting blog post about how to change databases under constant load.
Real short overview:
Basically first have to clone all data from old one to new DB and make application to write into both DBs at once (might do some delta migrations too, depending on your setup)
Then change reading from old DB to new DB but keep writing to both DBs just in case
If app is stable enough with new DB then stop writes to old DB
Finally some time later you can delete old DB

1 Like

thanks for the respond I´ve solved the issue by running this script
Insert into adonis_api_cliente.reclamacaos select * from selfcare.reclamacaos,

right Now I have another issue , When my server start I want to send a message , but I dont whish file is loaded when the adonisjs server start