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