Skip to content

Postgresql migrations endlessly tries to create enums #180

@Eugentis

Description

@Eugentis

We have PostgreSQL table state like:

create table logs
(
    ...,
    target      varchar(7)
        constraint logs_target_enum_62e2522d7df9c
            check ((target)::text = 'catalog'::text)
);

but cycle:migrate can't detect that field already have enum type and each next migration tries to fix it in next way:

class OrmDefault561cd35f5d5487d642a5bd8b65997299 extends Migration
{
    public function up(): void
    {        
        $this->table('logs')
            ->alterColumn('target', 'enum', [
                'nullable' => true,
                'default'  => null,
                'values'   => [
                    'catalog'
                ]
            ])
            ->update();
    }

    public function down(): void
    {
        $this->table('logs')
            ->alterColumn('target', 'string', [
                'nullable' => true,
                'default'  => null,
                'size'     => 7
            ])
            ->update();
    }
}

As I can see migrator can't understand that field already have enum functionality based on constraints

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Released

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions