title: Create database in Knex migration
body: <p>I thought it would be a good idea to start using migrations from the very first db interaction, so I'd like to create a migration for the database creation.</p>
  
  <p>knexfile.js</p>
  
  <pre><code>'use strict';
  
  require('dotenv').config({ path: 'process.env' });
  
  const config =  {
    client: 'pg',
    connection: {
      host: process.env.DB_URL,
    },
  };
  
  
  module.exports = config;
  </code></pre>
  
  <p>migration file:</p>
  
  <pre><code>'use strict';
  
  exports.up = function(knex, Promise) {
    return knex.raw('CREATE DATABASE asd');
  };
  
  exports.down = function(knex, Promise) {
    return knex.raw('DROP DATABASE asd');
  };
  
  exports.config = {
    transaction: false
  };
  </code></pre>
  
  <p>It works properly up to this point, but when I add <code>database</code> to the knexfile configuration, it fails to migrate as Knex tries to connect to the non existing database.</p>
  
  <p>I also tried to use a new Knex instance for this single migration like:</p>
  
  <pre><code>exports.up = function(_, Promise) {
    // Remove database from config so Knex won't try to connect
    // to a non existing database.
    const config = require(process.cwd() + '/knexfile');
    config.connection.database = null;
    const knex = require('knex')(config);
  
    return knex.raw('CREATE DATABASE asd');
  };
  </code></pre>
  
  <p>But knex is already initialized before the migration, so it fails with the same error:</p>
  
  <pre><code>error: database "asd" does not exist
  </code></pre>
  
  <p>Any ideas about how to create the database from a Knex migration? I'm open to any best practices about database creation, that can handle db urls for different environments.</p>