|
| 1 | +<?php |
| 2 | + |
| 3 | +use Illuminate\Database\Migrations\Migration; |
| 4 | +use Illuminate\Database\Schema\Blueprint; |
| 5 | + |
| 6 | +class CreateStatementIndexes extends Migration { |
| 7 | + |
| 8 | + /** |
| 9 | + * Run the migrations. |
| 10 | + * |
| 11 | + * @return void |
| 12 | + */ |
| 13 | + public function up() { |
| 14 | + $db = \DB::getMongoDB(); |
| 15 | + |
| 16 | + $indexOptions = ['background'=>1, 'socketTimeoutMS'=>-1]; |
| 17 | + $statements = new MongoCollection($db, 'statements'); |
| 18 | + |
| 19 | + $statements->createIndex(['statement.id' => 1, 'lrs_id' => 1], $indexOptions); |
| 20 | + $statements->createIndex(['statement.actor.mbox' => 1], $indexOptions); |
| 21 | + $statements->createIndex(['stored' => 1], $indexOptions); |
| 22 | + $statements->createIndex(['timestamp' => 1], $indexOptions); |
| 23 | + $statements->createIndex(['active' => 1], $indexOptions); |
| 24 | + $statements->createIndex(['voided' => 1], $indexOptions); |
| 25 | + $statements->createIndex(['lrs_id' => 1], $indexOptions); |
| 26 | + $statements->createIndex(['lrs_id' => 1, 'active' => -1, 'voided' => 1], $indexOptions); |
| 27 | + $statements->createIndex(['lrs_id' => 1, 'statement.actor.account.name' => 1, 'statement.actor.account.homePage' => 1], $indexOptions); |
| 28 | + $statements->createIndex(['lrs_id' => 1, 'statement.actor.mbox' => 1], $indexOptions); |
| 29 | + $statements->createIndex(['lrs_id' => 1, 'statement.verb.id' => 1], $indexOptions); |
| 30 | + $statements->createIndex(['lrs_id' => 1, 'statement.object.id' => 1], $indexOptions); |
| 31 | + $statements->createIndex(['lrs_id' => 1, 'stored' => -1], $indexOptions); |
| 32 | + $statements->createIndex(['lrs_id' => 1, 'timestamp' => -1], $indexOptions); |
| 33 | + } |
| 34 | + |
| 35 | + |
| 36 | + /** |
| 37 | + * Reverse the migrations. |
| 38 | + * |
| 39 | + * @return void |
| 40 | + */ |
| 41 | + public function down() |
| 42 | + { |
| 43 | + // we really don't want to remove this indexes |
| 44 | + } |
| 45 | + |
| 46 | +} |
0 commit comments