Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Postgresql migrations endlessly tries to create enums #180

Closed
Eugentis opened this issue Aug 3, 2022 · 1 comment · Fixed by #181
Closed

Postgresql migrations endlessly tries to create enums #180

Eugentis opened this issue Aug 3, 2022 · 1 comment · Fixed by #181
Assignees
Labels

Comments

@Eugentis
Copy link

Eugentis commented Aug 3, 2022

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

@roxblnfk roxblnfk added the type:bug Bug label Aug 3, 2022
@Eugentis
Copy link
Author

One more comment - it is actual only for cases when enum contains only one value

@msmakouz msmakouz self-assigned this Mar 29, 2024
@msmakouz msmakouz transferred this issue from cycle/migrations Mar 29, 2024
@msmakouz msmakouz linked a pull request Mar 29, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Released
Development

Successfully merging a pull request may close this issue.

3 participants