cli icon indicating copy to clipboard operation
cli copied to clipboard

Generate Raw SQL Queries for DB migrations

Open borislemke opened this issue 7 years ago • 7 comments

As suggested by @PascalPflaum [Collaborator at Umzug], I'm re-opening this issue from umzugs repo:

In rails, generating migrations will also generate an .sql file to be used with SQL. E.g, when creating a new migration, it will be accompanied with something like this file: 2103232813.sql

ALTER TABLE `products` CHANGE `group` `group` varchar(50) DEFAULT NULL
ALTER TABLE `products` CHANGE `person` `person` varchar(50) DEFAULT NULL
ALTER TABLE `products` CHANGE `store_name` `store_name` varchar(50) DEFAULT NULL

Is this possible with sequelize as well? At our company, engineers do not have access to production servers so we usually give the raw queries to our devops which they use to execute migrations on our production database.

I would appreciate if someone could guide me to the right direction to achieve this functionality.

borislemke avatar Oct 09 '17 06:10 borislemke

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment 🙂

stale[bot] avatar Jan 07 '18 07:01 stale[bot]

anyone else with this need? In my company we don't have permission to connect in production environment database to execute sequelize db:migrate, we need to send the sql scripts to DBA's. I tried to find out some way to just generate scripts instead execute them via sequelize cli but with no success at this moment.

rcarubbi avatar May 23 '18 15:05 rcarubbi

Please report this to https://github.com/sequelize/cli/ , I can't guarantee anything but this is something cli should support. We can keep feature request open so some day it can be implemented / contributed

sushantdhiman avatar May 23 '18 16:05 sushantdhiman

I am strongly looking for this. If someone has a solution for that, let me know please

Javad-Alirezaeyan avatar May 28 '21 09:05 Javad-Alirezaeyan

I have this same need using sequelize

kevin-bermudez avatar Feb 01 '22 00:02 kevin-bermudez

I've moved this to the cli project. This does not mean that it will be added any time soon, but people are more than welcome to contribute to this feature.

WikiRik avatar Feb 01 '22 11:02 WikiRik

Damn... this is a feature I needed Prisma ORM generates sql files that can be repetitively run so that everyone is on the same db build, we have the same need for our production database.. I didnt know Sequelize didn't support this before choosing this ORM. I saw migrations and assumed it all worked the same as the other ORMs. Oversight

chukwumaokere avatar Sep 06 '23 23:09 chukwumaokere