tpetry / laravel-postgresql-enhanced

Support for many missing PostgreSQL specific features
MIT License
772 stars 31 forks source link

Added methods to support custom data types. #92

Closed coolamit closed 3 months ago

coolamit commented 3 months ago

This is a followup to #91.

This PR adds support for custom data types - create, alter, and drop.

Schema facade gets these additions:

Schema::changeType(string $name, ?string $alteration = null): void
Schema::changeTypeName(string $name, string $newName): void
Schema::changeTypeToAddEnumValue(string $name, string $newValue): void
Schema::changeEnumTypeValueName(string $name, string $existingValue, string $newValue): void
Schema::createType(string $name, string $type): void
Schema::dropType(string ...$name): void
Schema::dropTypeIfExists(string ...$name): void

Blueprint class gets this addition

public function type(string $column, string $type): ColumnDefinition

The type() method above is just syntactic sugar, a wrapper around the domain() method, to allow for expressive code when assigning a custom data type to a column.

coolamit commented 3 months ago

@tpetry Please take a look

tpetry commented 3 months ago

Thanks for your contribution @coolamit but I won't merge this PR.

The PostgreSQL CREATE TYPE command is creating more trouble than it benefits an application from my experience: