]> BookStack Code Mirror - bookstack/blob - database/migrations/2015_07_12_114933_create_books_table.php
Merge branch 'master' into issue-181
[bookstack] / database / migrations / 2015_07_12_114933_create_books_table.php
1 <?php
2
3 use Illuminate\Database\Schema\Blueprint;
4 use Illuminate\Database\Migrations\Migration;
5
6 class CreateBooksTable extends Migration
7 {
8     /**
9      * Run the migrations.
10      *
11      * @return void
12      */
13     public function up()
14     {
15         $pdo = \DB::connection()->getPdo();
16         $mysqlVersion = $pdo->getAttribute(PDO::ATTR_SERVER_VERSION);
17         $requiresISAM = strpos($mysqlVersion, '5.5') === 0;
18
19         Schema::create('books', function (Blueprint $table) use ($requiresISAM) {
20                 if($requiresISAM) $table->engine = 'MyISAM';
21             
22             $table->increments('id');
23             $table->string('name');
24             $table->string('slug')->indexed();
25             $table->text('description');
26             $table->nullableTimestamps();
27         });
28     }
29
30     /**
31      * Reverse the migrations.
32      *
33      * @return void
34      */
35     public function down()
36     {
37         Schema::drop('books');
38     }
39 }