Skip to content

Commit

Permalink
Deprecate SchemaException codes
Browse files Browse the repository at this point in the history
  • Loading branch information
morozov committed Oct 7, 2022
1 parent ad25443 commit 610cf7e
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 11 deletions.
19 changes: 19 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,25 @@ awareness about deprecated code.

# Upgrade to 3.5

## Deprecated `SchemaException` error codes.

Relying on the error code of `SchemaException` is deprecated. In order to handle a specific type of exception,
catch the corresponding exception class instead.

| Error Code | Class |
|-----------------------------|--------------------------------|
| `TABLE_DOESNT_EXIST` | `TableDoesNotExist` |
| `TABLE_ALREADY_EXISTS` | `TableAlreadyExists` |
| `COLUMN_DOESNT_EXIST` | `ColumnDoesNotExist` |
| `COLUMN_ALREADY_EXISTS` | `ColumnAlreadyExists` |
| `INDEX_DOESNT_EXIST` | `IndexDoesNotExist` |
| `INDEX_ALREADY_EXISTS` | `IndexAlreadyExists` |
| `SEQUENCE_DOENST_EXIST` | `SequenceDoesNotExist` |
| `SEQUENCE_ALREADY_EXISTS` | `SequenceAlreadyExists` |
| `FOREIGNKEY_DOESNT_EXIST` | `ForeignKeyDoesNotExist` |
| `CONSTRAINT_DOESNT_EXIST` | `UniqueConstraintDoesNotExist` |
| `NAMESPACE_ALREADY_EXISTS` | `NamespaceAlreadyExists` |

## Deprecated fallback connection used to determine the database platform.

Relying on a fallback connection used to determine the database platform while connecting to a non-existing database
Expand Down
45 changes: 34 additions & 11 deletions src/Schema/SchemaException.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,40 @@
/** @psalm-immutable */
class SchemaException extends Exception
{
public const TABLE_DOESNT_EXIST = 10;
public const TABLE_ALREADY_EXISTS = 20;
public const COLUMN_DOESNT_EXIST = 30;
public const COLUMN_ALREADY_EXISTS = 40;
public const INDEX_DOESNT_EXIST = 50;
public const INDEX_ALREADY_EXISTS = 60;
public const SEQUENCE_DOENST_EXIST = 70;
public const SEQUENCE_ALREADY_EXISTS = 80;
public const INDEX_INVALID_NAME = 90;
public const FOREIGNKEY_DOESNT_EXIST = 100;
public const CONSTRAINT_DOESNT_EXIST = 110;
/** @deprecated Use {@see TableDoesNotExist} instead. */
public const TABLE_DOESNT_EXIST = 10;

/** @deprecated Use {@see TableAlreadyExists} instead. */
public const TABLE_ALREADY_EXISTS = 20;

/** @deprecated Use {@see ColumnDoesNotExist} instead. */
public const COLUMN_DOESNT_EXIST = 30;

/** @deprecated Use {@see ColumnAlreadyExists} instead. */
public const COLUMN_ALREADY_EXISTS = 40;

/** @deprecated Use {@see IndexDoesNotExist} instead. */
public const INDEX_DOESNT_EXIST = 50;

/** @deprecated Use {@see IndexAlreadyExists} instead. */
public const INDEX_ALREADY_EXISTS = 60;

/** @deprecated Use {@see SequenceDoesNotExist} instead. */
public const SEQUENCE_DOENST_EXIST = 70;

/** @deprecated Use {@see SequenceAlreadyExists} instead. */
public const SEQUENCE_ALREADY_EXISTS = 80;

/** @deprecated Use {@see IndexNameInvalid} instead. */
public const INDEX_INVALID_NAME = 90;

/** @deprecated Use {@see ForeignKeyDoesNotExist} instead. */
public const FOREIGNKEY_DOESNT_EXIST = 100;

/** @deprecated Use {@see UniqueConstraintDoesNotExist} instead. */
public const CONSTRAINT_DOESNT_EXIST = 110;

/** @deprecated Use {@see NamespaceAlreadyExists} instead. */
public const NAMESPACE_ALREADY_EXISTS = 120;

/**
Expand Down

0 comments on commit 610cf7e

Please sign in to comment.