|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace LaravelFreelancerNL\Aranguent\Migrations; |
|
6
|
|
|
|
|
7
|
|
|
use Illuminate\Database\ConnectionResolverInterface as IlluminateResolver; |
|
8
|
|
|
use Illuminate\Database\Migrations\DatabaseMigrationRepository as IlluminateDatabaseMigrationRepository; |
|
9
|
|
|
use LaravelFreelancerNL\Aranguent\Query\Builder; |
|
10
|
|
|
|
|
11
|
|
|
class DatabaseMigrationRepository extends IlluminateDatabaseMigrationRepository |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* The name of the migration collection. |
|
15
|
|
|
* |
|
16
|
|
|
* @var string |
|
17
|
|
|
*/ |
|
18
|
|
|
protected $table; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Create a new database migration repository instance. |
|
22
|
|
|
*/ |
|
23
|
|
|
public function __construct(IlluminateResolver $resolver, string $table) |
|
24
|
|
|
{ |
|
25
|
|
|
parent::__construct($resolver, $table); |
|
26
|
210 |
|
} |
|
27
|
|
|
|
|
28
|
210 |
|
/** |
|
29
|
|
|
* Create the migration repository data store. |
|
30
|
210 |
|
* |
|
31
|
210 |
|
* @return void |
|
32
|
|
|
*/ |
|
33
|
|
|
public function createRepository() |
|
34
|
|
|
{ |
|
35
|
|
|
$schemaManager = $this->getConnection()->getArangoClient()->schema(); |
|
36
|
|
|
|
|
37
|
|
|
$schemaManager->createCollection($this->table); |
|
38
|
164 |
|
} |
|
39
|
|
|
|
|
40
|
164 |
|
/** |
|
41
|
|
|
* Get the list of migrations. |
|
42
|
|
|
* |
|
43
|
|
|
* @param int $steps |
|
44
|
|
|
* @return array |
|
45
|
|
|
*/ |
|
46
|
|
|
public function getMigrations($steps) |
|
47
|
|
|
{ |
|
48
|
157 |
|
//TODO: the only difference with the parent function is that type of the batch value: |
|
49
|
|
|
// 1 instead of '1'. This should probably be changed in the Laravel framework as it |
|
50
|
157 |
|
// seems unnecessary to use a numeric string here. |
|
51
|
157 |
|
|
|
52
|
157 |
|
$query = $this->table() |
|
53
|
157 |
|
->where('batch', '>=', 1) |
|
54
|
|
|
->orderBy('batch', 'desc') |
|
55
|
157 |
|
->orderBy('migration', 'desc') |
|
56
|
|
|
->take($steps); |
|
57
|
|
|
|
|
58
|
|
|
return $query->get()->all(); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* Determine if the migration repository exists. |
|
64
|
|
|
* |
|
65
|
|
|
* @return bool |
|
66
|
|
|
*/ |
|
67
|
|
|
public function repositoryExists() |
|
68
|
|
|
{ |
|
69
|
|
|
$schemaManager = $this->getConnection()->getArangoClient()->schema(); |
|
70
|
1 |
|
|
|
71
|
|
|
return $schemaManager->hasCollection($this->table); |
|
72
|
1 |
|
|
|
73
|
1 |
|
// $schema = $this->getConnection()->getSchemaBuilder(); |
|
74
|
1 |
|
// |
|
75
|
1 |
|
// return $schema->hasCollection($this->table); |
|
76
|
1 |
|
} |
|
77
|
1 |
|
|
|
78
|
|
|
/** |
|
79
|
1 |
|
* Get a query builder for the migration collection. |
|
80
|
|
|
* |
|
81
|
|
|
* @return Builder |
|
82
|
138 |
|
*/ |
|
83
|
|
|
protected function collection() |
|
84
|
138 |
|
{ |
|
85
|
|
|
return $this->table(); |
|
86
|
138 |
|
} |
|
87
|
|
|
} |
|
88
|
|
|
|