Skip to content
Igor Savin edited this page Oct 19, 2018 · 25 revisions

Connecting to MSSQL on Azure SQL Database

{encrypt: true} should be included in options branch of connection configuration:

knex({
  client : 'mssql',
  connection: {
    database: 'mydatabase',
    server: 'myserver.database.windows.net',
    user: 'myuser',
    password: 'mypass',
    port: 1433,
    connectionTimeout: 30000,
    options: {
      encrypt: true
    }
  }
});

See all of node-mssql's connection options

Maintaining changelog for seeds (version >= 0.16.0-next1)

In case you would like to use Knex.js changelog functionality to ensure you environments are only seeded once, but don't want to mix seed files with migration files, you can specify multiple directories as a source for your migrations:

await knex.migrate.latest({
    directory: [
      'src/services/orders/database/migrations',
      'src/services/orders/database/seeds'
    ],
    sortDirsSeparately: true,
    tableName: ['orders_migrations'],
    schemaName: 'orders',  
})