-
-
Notifications
You must be signed in to change notification settings - Fork 76
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
Invalid ALTER TABLE statement for Postgresql after enum update #94
Comments
@el-seirh Please check this comment #31 (comment) |
That's exactly what I assumed. So ok... only field definition syntax is allowed. But then you still have the problem, that the ALTER TABLE statement is simply invalid. It cannot work. Even if you paste this directly into the database it will not work. Even when the previous check constraint was removed. What I'm trying to say here is that your mentioned Hook does not work for posgtgres. So ... we have to agree that it's simply not possible to create a valid field definition statement for postgres once the pseudo-enum has been created? |
Hi, this subject is old but I found an alternative to update enum in postgres using migration process.
Hope this can be helpful. |
so in a migration, one could include
Would it be possible to do this automatically when a migration is created (via diff)? |
Hi there
I have tested this bundle with an installation of a Postgresql 9.6 (current) database.
In the
\Fresh\DoctrineEnumBundle\DBAL\Types\AbstractEnumType::getSqlDeclaration()
function the bundle has a special return format for Postgresql:While this works perfectly for CREATE TABLE, it creates an invalid query for ALTER TABLE:
ALTER TABLE postal_address ALTER address_type TYPE VARCHAR(255) CHECK(address_type IN ('private', 'company', 'organisation'));
If at the moment I'd know how to make a valid ALTER TABLE statement using a check constraint I'd gladly provide you with a pull request. But I don't ;(.
If I had to do it manually I would drop the constraint and recreate it but I see that is not an easy thing to to in this context.
At the moment the migration works only once and will never work again when a EnumType changes.
Really cool would be real enum support (which is technically possible in Postgres) but neither do I know how to create an enum inside a CREATE TABLE statement. I don't really think that's possible. You'd need CREATE TYPE.
Regards
The text was updated successfully, but these errors were encountered: