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

Migrations do not work on Postgresql #24

Closed
alxkolm opened this issue Nov 1, 2016 · 7 comments
Closed

Migrations do not work on Postgresql #24

alxkolm opened this issue Nov 1, 2016 · 7 comments

Comments

@alxkolm
Copy link

alxkolm commented Nov 1, 2016

Migrations do not work on Postgresql. Migration class m161004_132206_change_action_field

*** applying m161004_132206_change_action_field
    > alter column action in table tbl_audit_trail to ENUM('CHANGE', 'CREATE', 'DELETE', 'SET') NOT NULL ...Exception 'yii\db\Exception' with message 'SQLSTATE[42601]: Syntax error: 7 ERROR:  syntax error at or near "NOT"
LINE 1: ...ion" TYPE ENUM('CHANGE', 'CREATE', 'DELETE', 'SET') NOT NULL
                                                               ^
The SQL being executed was: ALTER TABLE "tbl_audit_trail" ALTER COLUMN "action" TYPE ENUM('CHANGE', 'CREATE', 'DELETE', 'SET') NOT NULL'
@alxkolm
Copy link
Author

alxkolm commented Nov 1, 2016

I think it is not necessary restrict column by ENUM type, because people want to set custom values in action

@uldisn
Copy link
Contributor

uldisn commented Nov 1, 2016

Using ENUM is small optimization. My suggestion is in migration execute altering to ENUM only, if MySql.

 if ($this->db->driverName === 'mysql') {
}

@alxkolm
Copy link
Author

alxkolm commented Nov 1, 2016

But whenever I want set custom action I need alter column schema. It's very tedious.

@Sammaye
Copy link
Owner

Sammaye commented Nov 1, 2016

I thought the enum change was a bad idea

On 1 November 2016 at 14:12, Kolmakov Alexey notifications@github.com
wrote:

But whenever I want set custom action I need alter column schema. It's
very tedious.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#24 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AATxnPbV77qNbQGQmM6PqrRs8P9p8WWxks5q50jOgaJpZM4KmBq0
.

@Sammaye
Copy link
Owner

Sammaye commented Nov 1, 2016

Even for mysql users, this scenario is a common one whereby enum would cause too much application logic in the database. Current thinking is that the database should be dumb to the application rather than have two layers of validation at times, especially with very large tables spanning 30 million+ records, which audit tables can

@Sammaye
Copy link
Owner

Sammaye commented Nov 1, 2016

I have decided to remove this for the time being 8e38c7f I think it is more trouble than it is worth

@Sammaye Sammaye closed this as completed Nov 1, 2016
@alxkolm
Copy link
Author

alxkolm commented Nov 1, 2016

Fully agree

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

No branches or pull requests

3 participants