sequelize / cli

The Sequelize CLI
MIT License
2.53k stars 526 forks source link

Generate Raw SQL Queries for DB migrations #998

Open borislemke opened 7 years ago

borislemke commented 7 years ago

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.

stale[bot] commented 6 years ago

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 🙂

rcarubbi commented 6 years ago

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.

sushantdhiman commented 6 years ago

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

Javad-Alirezaeyan commented 3 years ago

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

kevin-bermudez commented 2 years ago

I have this same need using sequelize

WikiRik commented 2 years ago

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.

chukwumaokere commented 1 year ago

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