-
Notifications
You must be signed in to change notification settings - Fork 243
Expand file tree
/
Copy pathUpgradeCreator.php
More file actions
60 lines (53 loc) · 1.43 KB
/
UpgradeCreator.php
File metadata and controls
60 lines (53 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
namespace ProcessMaker\Upgrades;
use Illuminate\Database\Migrations\MigrationCreator;
use ProcessMaker\Exception\InvalidSemanticVersion;
class UpgradeCreator extends MigrationCreator
{
/**
* Create a new upgrade migration file at the given path
*
* @param $name
* @param $path
* @param null $to
* @param null $optional
*
* @return string
*
* @throws \ProcessMaker\Exception\InvalidSemanticVersion
*/
public function createUpgrade($name, $path)
{
$this->ensureMigrationDoesntAlreadyExist($name, $path);
$this->files->put(
$path = $this->getPath($name, $path),
$this->populateUpgradeStub($name, $this->getStub(null, null))
);
return $path;
}
/**
* Overrides the default migration stubs path to return the
* upgrade migration specific stubs directory path
*
* @return string
*/
public function stubPath()
{
return base_path('stubs/upgrades');
}
/**
* Populate the place-holders in the upgrade migration stub.
*
* @param $name
* @param $stub
* @param $from
* @param $to
* @param bool $optional
*
* @return array|string|string[]
*/
protected function populateUpgradeStub($name, $stub, $to = null, bool $optional = false)
{
return str_replace('DummyUpgradeClass', $this->getClassName($name), $stub);
}
}