Skip to content

Raw sql migrations support #3

@shedar

Description

@shedar

Knex has a powerful schema builder. But, as you mentioned in knex 2015 roadmap, it’s still limited. I’d suggest to add a raw sql migrations.
Each migration will have two files: datetime_name_up.sql and datetime_name_down.sql

For now I use following code in migration js file for raw migrations

var migrationUtils = require('../../src/helpers/migrations/migrations');
exports.up = migrationUtils.getUpFunction(__filename);
exports.down = migrationUtils.getDownFunction(__filename);

each of functions reads corresponding (_up or _down) sql file and executes knex.raw with its content. But it causes repeating of each migration js code and gives 3 files per migration.
I can also put raw sql in js, but it’ll break sql syntax highlight and reduce readability.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions