With the `qb` schema builder can I capture and dum...
# box-products
d
With the
qb
schema builder can I capture and dump the
SQL
produced by a
schema.alter()
so I can replay it on my prod db?
e
Yes. https://qb.ortusbooks.com/schema-builder/alter If you set
execute
to
false
then you get back a
SchemaBuilder
object that you can call
toSQL()
on.
d
Sorry, I got distracted. is this what you meant?
Copy code
function up( schema ) {
	var query = schema.alter( 'members', function ( table ) {
		table.addColumn( table.unsignedInteger( 'distributionRound' ).nullable() );
	} );

	writedump( var='#query.toSQL()#', output='console' );
}
e
Yes, but you need to pass
execute = false
to the alter call.
d
Gotcha, thanks.