Version: Next
object-name-length
Why?
Database vendors vary in what length of object (table, column, constraint etc) names they support. If your project works across multiple vendors, you might find a script could fail on some databases when it has already run successfully on some others, due to the object name length. This then requires manual intervention to fix, which is prone to further mistakes.
For example:
- SQL Server supports 128 characters, and has done since at least 2008
- Oracle only supported up to 30 characters until 12.2 when it changed to 128 characters - but earlier versions are still in widespread use, especially in enterprise settings
- MySQL supports up to 64 characters
- PostgreSQL supports up to 63 characters - but will automatically truncate longer names and use the result, without erroring ¯\_(ツ)_/¯
- H2 apparently has no limits on object names
This rule will fail if the given maximum length is exceeded by the name for any:
- Table
- Column
- View
- Primary key
- Foreign key constraint
- Unique constraint
- Index
Options
maxLength
- (number) the maximum length of the name of any schema object to be created
Example Usage
{
"rules": {
"object-name-length": {
"maxLength": 63
}
}
}