Skip to content
This repository has been archived by the owner on Mar 30, 2023. It is now read-only.

Generate diff migration always dump Enum columns #4

Closed
jonbk opened this issue Jan 3, 2022 · 0 comments · Fixed by #5
Closed

Generate diff migration always dump Enum columns #4

jonbk opened this issue Jan 3, 2022 · 0 comments · Fixed by #5

Comments

@jonbk
Copy link
Contributor

jonbk commented Jan 3, 2022

Example :

Creating the following initial table third_party :

        'CREATE TABLE third_party (
              id SERIAL NOT NULL, 
              name VARCHAR(255) NOT NULL, 
              type VARCHAR(255) NOT NULL, 
              address VARCHAR(1024) DEFAULT NULL, 
              post_code VARCHAR(10) DEFAULT NULL, 
              city VARCHAR(128) DEFAULT NULL, 
              country VARCHAR(255) NOT NULL, 
              PRIMARY KEY(id))
          ');

Where type and country are both of them BackedEnum. If I execute this migration, and regenarate a diff migration, it will always reconfigure this 2 columns definition :

     ALTER TABLE third_party ALTER type TYPE VARCHAR(255);
     ALTER TABLE third_party ALTER type DROP DEFAULT;
     ALTER TABLE third_party ALTER country TYPE VARCHAR(255);
     ALTER TABLE third_party ALTER country DROP DEFAULT;

By searching on the migrations packages, the changes seems to be detected like this (for country) :

Before change :

^ Doctrine\DBAL\Schema\Column^ {#347
  #_name: "country"
  #_namespace: null
  #_quoted: false
  #_type: Doctrine\DBAL\Types\StringType^ {#123}
  #_length: 255
  #_precision: 10
  #_scale: 0
  #_unsigned: false
  #_fixed: false
  #_notnull: true
  #_default: null
  #_autoincrement: false
  #_platformOptions: []
  #_columnDefinition: null
  #_comment: null
  #_customSchemaOptions: []
}

After change :

Doctrine\DBAL\Schema\Column^ {#302
  #_name: "country"
  #_namespace: null
  #_quoted: false
  #_type: BenTools\Doctrine\NativeEnums\Type\NativeEnum^ {#115
    -name: "App\Enum\CountryEnum"
    -class: "App\Enum\CountryEnum"
    -type: BenTools\Doctrine\NativeEnums\Type\BackedEnumType^ {#116
      +name: "STRING"
    }
  }
  #_length: null
  #_precision: 10
  #_scale: 0
  #_unsigned: false
  #_fixed: false
  #_notnull: true
  #_default: null
  #_autoincrement: false
  #_platformOptions: array:1 [
    "version" => false
  ]
  #_columnDefinition: null
  #_comment: null
  #_customSchemaOptions: []
}

I'm trying to find a solution right now.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant