knex-migrate-sql-file

    1.0.3 • Public • Published

    knex-migrate-sql-file

    Use sql files instead of knex.schema methods.

    Exports up and down functions whichs executes knex.raw() method on SQL files having same file name appended .up.sql and .down.sql.

    Synopsis

    1. Create knex migration file
    2. Import this library in migration file
    3. Create SQL files
    $ knex migrate:make add-user-table
    Created Migration: /some/path/20180516163212_add-user-table.js

    /some/path/20180516163212_add-user-table.js

    //                    Don't forget function call ⤵
    module.exports = require("knex-migrate-sql-file")();

    /some/path/20180516163212_add-user-table.up.sql

    CREATE TABLE "user"

    /some/path/20180516163212_add-user-table.down.sql

    DROP TABLE "user"

    You can override up or down function according to your needs.

    API

    Functions

    up(knex, Promise)

    Reads .up.sql file and executes it using knex.raw() method.

    down(knex, Promise)

    Reads .down.sql file and executes it using knex.raw() method.

    up(knex, Promise)

    Reads .up.sql file and executes it using knex.raw() method.

    Kind: global function

    Param Type Description
    knex Knex Knex object
    Promise Promise Promise

    Example

    module.exports = require("knex-migrate-sql-file")();

    down(knex, Promise)

    Reads .down.sql file and executes it using knex.raw() method.

    Kind: global function

    Param Type Description
    knex Knex Knex object
    Promise Promise Promise

    Example

    module.exports = require("knex-migrate-sql-file")();

    Install

    npm i knex-migrate-sql-file

    DownloadsWeekly Downloads

    862

    Version

    1.0.3

    License

    MIT

    Unpacked Size

    7.95 kB

    Total Files

    11

    Last publish

    Collaborators

    • ozum