Closed maxsummers closed 6 years ago
Duplicate of #401
@maxsummers Please have a look in the other issue I linked above and read my comments over there, I have already stated about some things that need to be in place to actually do what you ask for.
Fact is: SQL migrations currently do not exist, there is just a template and you basically still use javascript migrations. So yes this is true, but this is a migration framework that started with just javascript, so this is nothing that would be unexpected. So far there are plans to support raw SQL in a more native way, just like this is true now for es6
or coffeescript
, for SQL as it does not use the abstractions and is not getting transpiled, there needs to be a few more things to be done and thought about though. As said above take a look over there in the other issue.
@maxsummers this was driving me nuts so I pulled the boilerplate out into a separate package that you can use:
https://www.npmjs.com/package/db-migrate-boilerplate
This simplifies what you're committing into your repo to:
'use strict'
const path = require('path')
const boilerplate = require('db-migrate-boilerplate')
module.exports = boilerplate({
upPath: path.join(__dirname, 'sqls', '20161226111110-test-up.sql'),
downPath: path.join(__dirname, 'sqls', '20161226111110-test-down.sql')
})
@troygoode :) +1
I've made some thoughts about that again, and it might be quite a good option to handle the word sqls
as a keyword that can not be used to name a scope, just like all
. That way the problem described in the other issue wouldn't exist anymore and a name schema like the already existing ones would work to directly execute sqls.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
When
sql-file
option is used it creates the following migration file:This is a huge amount of non-optimized boilerplate code.
It's pretty common to have hundreds of migrations in actively developed project. Now, consider this boilerplate multiplied by one hundred. This will increase code base size significantly and will take additional time for IDE to analyze the code and build it's indices.
Please, consider to reduce the size of such migration files. I think the only relevant part of it is:
__dirname, 'sqls', '20161226111110-test-down.sql'
, so everything else could be moved to the library code.