Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

borrie's avatar

Query from Migration

I need to update the database inside my production environment. I want to expand a table to a many-to-many relationship. In order to do this I need to execute a query to copy rows from one table to another.

I don't want to dump the database from production to dev and execute the query's manually. I wonder if I am able to run the particular query from a migration, since it has to be run only once.

0 likes
3 replies
tykus's avatar

Why write a migration at all; do you have access directly to the database using either commandline or GUI clients?

borrie's avatar

I do have access to the database from terminal.

tykus's avatar

In your mind, what is the benefit of a migration in that case? If you are moving data, then I would need a compelling reason to write PHP code to generate the SQL to do that.

Please or to participate in this conversation.