-
Notifications
You must be signed in to change notification settings - Fork 277
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for generating indexes (#351)
- Loading branch information
1 parent
62edefe
commit a0d0655
Showing
9 changed files
with
175 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace Blueprint\Models; | ||
|
||
class Index | ||
{ | ||
private $type; | ||
private $columns; | ||
|
||
public function __construct(string $type, array $columns = []) | ||
{ | ||
$this->type = $type; | ||
$this->columns = $columns; | ||
} | ||
|
||
public function type() | ||
{ | ||
return $this->type; | ||
} | ||
|
||
public function columns() | ||
{ | ||
return $this->columns; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
models: | ||
Post: | ||
id: unsignedInteger | ||
title: string | ||
parent_post_id: id | ||
author_id: id | ||
published_at: timestamp nullable | ||
word_count: integer unsigned | ||
location: geometry | ||
indexes: | ||
- primary: id | ||
- index: author_id | ||
- index: author_id, published_at | ||
- unique: title | ||
- unique: title, parent_post_id | ||
- spatialIndex: location |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
class CreatePostsTable extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
Schema::create('posts', function (Blueprint $table) { | ||
$table->unsignedInteger('id'); | ||
$table->string('title'); | ||
$table->unsignedBigInteger('parent_post_id'); | ||
$table->unsignedBigInteger('author_id'); | ||
$table->timestamp('published_at')->nullable(); | ||
$table->unsignedInteger('word_count'); | ||
$table->geometry('location'); | ||
$table->primary('id'); | ||
$table->index('author_id'); | ||
$table->index(['author_id', 'published_at']); | ||
$table->unique('title'); | ||
$table->unique(['title', 'parent_post_id']); | ||
$table->spatialIndex('location'); | ||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
Schema::dropIfExists('posts'); | ||
} | ||
} |