1 | <?php |
---|
2 | |
---|
3 | namespace Doctrine\DBAL\Schema; |
---|
4 | |
---|
5 | class SchemaException extends \Doctrine\DBAL\DBALException |
---|
6 | { |
---|
7 | const TABLE_DOESNT_EXIST = 10; |
---|
8 | const TABLE_ALREADY_EXISTS = 20; |
---|
9 | const COLUMN_DOESNT_EXIST = 30; |
---|
10 | const COLUMN_ALREADY_EXISTS = 40; |
---|
11 | const INDEX_DOESNT_EXIST = 50; |
---|
12 | const INDEX_ALREADY_EXISTS = 60; |
---|
13 | const SEQUENCE_DOENST_EXIST = 70; |
---|
14 | const SEQUENCE_ALREADY_EXISTS = 80; |
---|
15 | const INDEX_INVALID_NAME = 90; |
---|
16 | const FOREIGNKEY_DOESNT_EXIST = 100; |
---|
17 | |
---|
18 | /** |
---|
19 | * @param string $tableName |
---|
20 | * @return SchemaException |
---|
21 | */ |
---|
22 | static public function tableDoesNotExist($tableName) |
---|
23 | { |
---|
24 | return new self("There is no table with name '".$tableName."' in the schema.", self::TABLE_DOESNT_EXIST); |
---|
25 | } |
---|
26 | |
---|
27 | /** |
---|
28 | * @param string $indexName |
---|
29 | * @return SchemaException |
---|
30 | */ |
---|
31 | static public function indexNameInvalid($indexName) |
---|
32 | { |
---|
33 | return new self("Invalid index-name $indexName given, has to be [a-zA-Z0-9_]", self::INDEX_INVALID_NAME); |
---|
34 | } |
---|
35 | |
---|
36 | /** |
---|
37 | * @param string $indexName |
---|
38 | * @return SchemaException |
---|
39 | */ |
---|
40 | static public function indexDoesNotExist($indexName, $table) |
---|
41 | { |
---|
42 | return new self("Index '$indexName' does not exist on table '$table'.", self::INDEX_DOESNT_EXIST); |
---|
43 | } |
---|
44 | |
---|
45 | /** |
---|
46 | * @param string $indexName |
---|
47 | * @return SchemaException |
---|
48 | */ |
---|
49 | static public function indexAlreadyExists($indexName, $table) |
---|
50 | { |
---|
51 | return new self("An index with name '$indexName' was already defined on table '$table'.", self::INDEX_ALREADY_EXISTS); |
---|
52 | } |
---|
53 | |
---|
54 | /** |
---|
55 | * @param string $columnName |
---|
56 | * @return SchemaException |
---|
57 | */ |
---|
58 | static public function columnDoesNotExist($columnName, $table) |
---|
59 | { |
---|
60 | return new self("There is no column with name '$columnName' on table '$table'.", self::COLUMN_DOESNT_EXIST); |
---|
61 | } |
---|
62 | |
---|
63 | /** |
---|
64 | * |
---|
65 | * @param string $tableName |
---|
66 | * @return SchemaException |
---|
67 | */ |
---|
68 | static public function tableAlreadyExists($tableName) |
---|
69 | { |
---|
70 | return new self("The table with name '".$tableName."' already exists.", self::TABLE_ALREADY_EXISTS); |
---|
71 | } |
---|
72 | |
---|
73 | /** |
---|
74 | * |
---|
75 | * @param string $tableName |
---|
76 | * @param string $columnName |
---|
77 | * @return SchemaException |
---|
78 | */ |
---|
79 | static public function columnAlreadyExists($tableName, $columnName) |
---|
80 | { |
---|
81 | return new self( |
---|
82 | "The column '".$columnName."' on table '".$tableName."' already exists.", self::COLUMN_ALREADY_EXISTS |
---|
83 | ); |
---|
84 | } |
---|
85 | |
---|
86 | /** |
---|
87 | * @param string $sequenceName |
---|
88 | * @return SchemaException |
---|
89 | */ |
---|
90 | static public function sequenceAlreadyExists($sequenceName) |
---|
91 | { |
---|
92 | return new self("The sequence '".$sequenceName."' already exists.", self::SEQUENCE_ALREADY_EXISTS); |
---|
93 | } |
---|
94 | |
---|
95 | /** |
---|
96 | * @param string $sequenceName |
---|
97 | * @return SchemaException |
---|
98 | */ |
---|
99 | static public function sequenceDoesNotExist($sequenceName) |
---|
100 | { |
---|
101 | return new self("There exists no sequence with the name '".$sequenceName."'.", self::SEQUENCE_DOENST_EXIST); |
---|
102 | } |
---|
103 | |
---|
104 | /** |
---|
105 | * @param string $fkName |
---|
106 | * @return SchemaException |
---|
107 | */ |
---|
108 | static public function foreignKeyDoesNotExist($fkName, $table) |
---|
109 | { |
---|
110 | return new self("There exists no foreign key with the name '$fkName' on table '$table'.", self::FOREIGNKEY_DOESNT_EXIST); |
---|
111 | } |
---|
112 | |
---|
113 | static public function namedForeignKeyRequired(Table $localTable, ForeignKeyConstraint $foreignKey) |
---|
114 | { |
---|
115 | return new self( |
---|
116 | "The performed schema operation on ".$localTable->getName()." requires a named foreign key, ". |
---|
117 | "but the given foreign key from (".implode(", ", $foreignKey->getColumns()).") onto foreign table ". |
---|
118 | "'".$foreignKey->getForeignTableName()."' (".implode(", ", $foreignKey->getForeignColumns()).") is currently ". |
---|
119 | "unnamed." |
---|
120 | ); |
---|
121 | } |
---|
122 | |
---|
123 | static public function alterTableChangeNotSupported($changeName) { |
---|
124 | return new self ("Alter table change not supported, given '$changeName'"); |
---|
125 | } |
---|
126 | } |
---|