29.07.2016 Views

laravel-5

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Database: Migrations 417<br />

.<br />

1 if (Schema::hasTable('users')) {<br />

2 //<br />

3 }<br />

4<br />

5 if (Schema::hasColumn('users', 'email')) {<br />

6 //<br />

7 }<br />

Connection & Storage Engine<br />

If you want to perform a schema operation on a database connection that is not your default<br />

connection, use the connection method:<br />

.<br />

1 Schema::connection('foo')->create('users', function ($table) {<br />

2 $table->increments('id');<br />

3 });<br />

To set the storage engine for a table, set the engine property on the schema builder:<br />

.<br />

1 Schema::create('users', function ($table) {<br />

2 $table->engine = 'InnoDB';<br />

3<br />

4 $table->increments('id');<br />

5 });<br />

Renaming / Dropping Tables<br />

To rename an existing database table, use the rename method:<br />

.<br />

1 Schema::rename($from, $to);<br />

To drop an existing table, you may use the drop or dropIfExists methods:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!