|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Doctrine\DBAL\Migrations; |
|
4
|
|
|
|
|
5
|
|
|
use \Doctrine\DBAL\Migrations\Finder\MigrationFinderInterface; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* Class for Migrations specific exceptions |
|
9
|
|
|
* |
|
10
|
|
|
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL |
|
11
|
|
|
* @link www.doctrine-project.org |
|
12
|
|
|
* @since 2.0 |
|
13
|
|
|
* @author Jonathan H. Wage <[email protected]> |
|
14
|
|
|
*/ |
|
15
|
|
|
class MigrationException extends \Exception |
|
16
|
|
|
{ |
|
17
|
10 |
|
public static function migrationsNamespaceRequired() |
|
18
|
|
|
{ |
|
19
|
10 |
|
return new self('Migrations namespace must be configured in order to use Doctrine migrations.', 2); |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
10 |
|
public static function migrationsDirectoryRequired() |
|
23
|
|
|
{ |
|
24
|
10 |
|
return new self('Migrations directory must be configured in order to use Doctrine migrations.', 3); |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
1 |
|
public static function noMigrationsToExecute() |
|
28
|
|
|
{ |
|
29
|
1 |
|
return new self('Could not find any migrations to execute.', 4); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
3 |
|
public static function unknownMigrationVersion($version) |
|
33
|
|
|
{ |
|
34
|
3 |
|
return new self(sprintf('Could not find migration version %s', $version), 5); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
public static function alreadyAtVersion($version) |
|
38
|
|
|
{ |
|
39
|
|
|
return new self(sprintf('Database is already at version %s', $version), 6); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
1 |
|
public static function duplicateMigrationVersion($version, $class) |
|
43
|
|
|
{ |
|
44
|
1 |
|
return new self(sprintf('Migration version %s already registered with class %s', $version, $class), 7); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
4 |
|
public static function configurationFileAlreadyLoaded() |
|
48
|
|
|
{ |
|
49
|
4 |
|
return new self(sprintf('Migrations configuration file already loaded'), 8); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
public static function yamlConfigurationNotAvailable() : self |
|
53
|
|
|
{ |
|
54
|
|
|
return new self('Unable to load yaml configuration files, please `composer require symfony/yaml` load yaml configuration files'); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
8 |
|
public static function configurationIncompatibleWithFinder( |
|
58
|
|
|
$configurationParameterName, |
|
59
|
|
|
MigrationFinderInterface $finder |
|
60
|
|
|
) { |
|
61
|
8 |
|
return new self( |
|
62
|
8 |
|
sprintf( |
|
63
|
8 |
|
'Configuration-parameter "%s" cannot be used with finder of type "%s"', |
|
64
|
8 |
|
$configurationParameterName, |
|
65
|
8 |
|
get_class($finder) |
|
66
|
|
|
), |
|
67
|
8 |
|
9 |
|
68
|
|
|
); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
8 |
|
public static function configurationNotValid($msg) |
|
72
|
|
|
{ |
|
73
|
8 |
|
return new self($msg, 10); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* @param string $migrationClass |
|
78
|
|
|
* @param string $migrationNamespace |
|
79
|
|
|
* @return MigrationException |
|
80
|
|
|
*/ |
|
81
|
1 |
|
public static function migrationClassNotFound($migrationClass, $migrationNamespace) |
|
82
|
|
|
{ |
|
83
|
1 |
|
return new self( |
|
84
|
1 |
|
sprintf( |
|
85
|
1 |
|
'Migration class "%s" was not found. Is it placed in "%s" namespace?', |
|
86
|
1 |
|
$migrationClass, |
|
87
|
1 |
|
$migrationNamespace |
|
88
|
|
|
) |
|
89
|
|
|
); |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* @param string $migrationClass |
|
94
|
|
|
* @return MigrationException |
|
95
|
|
|
*/ |
|
96
|
1 |
|
public static function migrationNotConvertibleToSql($migrationClass) |
|
97
|
|
|
{ |
|
98
|
1 |
|
return new self( |
|
99
|
1 |
|
sprintf( |
|
100
|
1 |
|
'Migration class "%s" contains a prepared statement. |
|
101
|
|
|
Unfortunately there is no cross platform way of outputing it as an sql string. |
|
102
|
|
|
Do you want to write a PR for it ?', |
|
103
|
1 |
|
$migrationClass |
|
104
|
|
|
) |
|
105
|
|
|
); |
|
106
|
|
|
} |
|
107
|
|
|
} |
|
108
|
|
|
|