Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
namespace Doctrine\DBAL\Schema;
4
 
5
use Doctrine\DBAL\Exception;
6
use Doctrine\DBAL\Schema\Exception\ColumnAlreadyExists;
7
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
8
use Doctrine\DBAL\Schema\Exception\ForeignKeyDoesNotExist;
9
use Doctrine\DBAL\Schema\Exception\IndexAlreadyExists;
10
use Doctrine\DBAL\Schema\Exception\IndexDoesNotExist;
11
use Doctrine\DBAL\Schema\Exception\IndexNameInvalid;
12
use Doctrine\DBAL\Schema\Exception\NamedForeignKeyRequired;
13
use Doctrine\DBAL\Schema\Exception\NamespaceAlreadyExists;
14
use Doctrine\DBAL\Schema\Exception\SequenceAlreadyExists;
15
use Doctrine\DBAL\Schema\Exception\SequenceDoesNotExist;
16
use Doctrine\DBAL\Schema\Exception\TableAlreadyExists;
17
use Doctrine\DBAL\Schema\Exception\TableDoesNotExist;
18
use Doctrine\DBAL\Schema\Exception\UniqueConstraintDoesNotExist;
19
 
20
use function sprintf;
21
 
22
/** @psalm-immutable */
23
class SchemaException extends Exception
24
{
25
    /** @deprecated Use {@see TableDoesNotExist} instead. */
26
    public const TABLE_DOESNT_EXIST = 10;
27
 
28
    /** @deprecated Use {@see TableAlreadyExists} instead. */
29
    public const TABLE_ALREADY_EXISTS = 20;
30
 
31
    /** @deprecated Use {@see ColumnDoesNotExist} instead. */
32
    public const COLUMN_DOESNT_EXIST = 30;
33
 
34
    /** @deprecated Use {@see ColumnAlreadyExists} instead. */
35
    public const COLUMN_ALREADY_EXISTS = 40;
36
 
37
    /** @deprecated Use {@see IndexDoesNotExist} instead. */
38
    public const INDEX_DOESNT_EXIST = 50;
39
 
40
    /** @deprecated Use {@see IndexAlreadyExists} instead. */
41
    public const INDEX_ALREADY_EXISTS = 60;
42
 
43
    /** @deprecated Use {@see SequenceDoesNotExist} instead. */
44
    public const SEQUENCE_DOENST_EXIST = 70;
45
 
46
    /** @deprecated Use {@see SequenceAlreadyExists} instead. */
47
    public const SEQUENCE_ALREADY_EXISTS = 80;
48
 
49
    /** @deprecated Use {@see IndexNameInvalid} instead. */
50
    public const INDEX_INVALID_NAME = 90;
51
 
52
    /** @deprecated Use {@see ForeignKeyDoesNotExist} instead. */
53
    public const FOREIGNKEY_DOESNT_EXIST = 100;
54
 
55
    /** @deprecated Use {@see UniqueConstraintDoesNotExist} instead. */
56
    public const CONSTRAINT_DOESNT_EXIST = 110;
57
 
58
    /** @deprecated Use {@see NamespaceAlreadyExists} instead. */
59
    public const NAMESPACE_ALREADY_EXISTS = 120;
60
 
61
    /**
62
     * @param string $tableName
63
     *
64
     * @return SchemaException
65
     */
66
    public static function tableDoesNotExist($tableName)
67
    {
68
        return TableDoesNotExist::new($tableName);
69
    }
70
 
71
    /**
72
     * @param string $indexName
73
     *
74
     * @return SchemaException
75
     */
76
    public static function indexNameInvalid($indexName)
77
    {
78
        return IndexNameInvalid::new($indexName);
79
    }
80
 
81
    /**
82
     * @param string $indexName
83
     * @param string $table
84
     *
85
     * @return SchemaException
86
     */
87
    public static function indexDoesNotExist($indexName, $table)
88
    {
89
        return IndexDoesNotExist::new($indexName, $table);
90
    }
91
 
92
    /**
93
     * @param string $indexName
94
     * @param string $table
95
     *
96
     * @return SchemaException
97
     */
98
    public static function indexAlreadyExists($indexName, $table)
99
    {
100
        return IndexAlreadyExists::new($indexName, $table);
101
    }
102
 
103
    /**
104
     * @param string $columnName
105
     * @param string $table
106
     *
107
     * @return SchemaException
108
     */
109
    public static function columnDoesNotExist($columnName, $table)
110
    {
111
        return ColumnDoesNotExist::new($columnName, $table);
112
    }
113
 
114
    /**
115
     * @param string $namespaceName
116
     *
117
     * @return SchemaException
118
     */
119
    public static function namespaceAlreadyExists($namespaceName)
120
    {
121
        return NamespaceAlreadyExists::new($namespaceName);
122
    }
123
 
124
    /**
125
     * @param string $tableName
126
     *
127
     * @return SchemaException
128
     */
129
    public static function tableAlreadyExists($tableName)
130
    {
131
        return TableAlreadyExists::new($tableName);
132
    }
133
 
134
    /**
135
     * @param string $tableName
136
     * @param string $columnName
137
     *
138
     * @return SchemaException
139
     */
140
    public static function columnAlreadyExists($tableName, $columnName)
141
    {
142
        return ColumnAlreadyExists::new($tableName, $columnName);
143
    }
144
 
145
    /**
146
     * @param string $name
147
     *
148
     * @return SchemaException
149
     */
150
    public static function sequenceAlreadyExists($name)
151
    {
152
        return SequenceAlreadyExists::new($name);
153
    }
154
 
155
    /**
156
     * @param string $name
157
     *
158
     * @return SchemaException
159
     */
160
    public static function sequenceDoesNotExist($name)
161
    {
162
        return SequenceDoesNotExist::new($name);
163
    }
164
 
165
    /**
166
     * @param string $constraintName
167
     * @param string $table
168
     *
169
     * @return SchemaException
170
     */
171
    public static function uniqueConstraintDoesNotExist($constraintName, $table)
172
    {
173
        return UniqueConstraintDoesNotExist::new($constraintName, $table);
174
    }
175
 
176
    /**
177
     * @param string $fkName
178
     * @param string $table
179
     *
180
     * @return SchemaException
181
     */
182
    public static function foreignKeyDoesNotExist($fkName, $table)
183
    {
184
        return ForeignKeyDoesNotExist::new($fkName, $table);
185
    }
186
 
187
    /** @return SchemaException */
188
    public static function namedForeignKeyRequired(Table $localTable, ForeignKeyConstraint $foreignKey)
189
    {
190
        return NamedForeignKeyRequired::new($localTable, $foreignKey);
191
    }
192
 
193
    /**
194
     * @param string $changeName
195
     *
196
     * @return SchemaException
197
     */
198
    public static function alterTableChangeNotSupported($changeName)
199
    {
200
        return new self(
201
            sprintf("Alter table change not supported, given '%s'", $changeName),
202
        );
203
    }
204
}