A
A
Alexander Wolf2014-07-27 16:30:20
PostgreSQL
Alexander Wolf, 2014-07-27 16:30:20

How to make field NOT NULL PostgreSQL Yii2 Alter Table?

Hello! I have a migration in which the result field of the transactions table must be made NOT NULL .
If use

$this->alterColumn('transactions', 'result', Schema::TYPE_INTEGER . ' SET NOT NULL');
Then the error Syntax error: 7 ERROR: syntax error at or near "set" takes off . If you remove SET , then the error falls out on the word NOT , etc.
And so a question: how to make a field NOT NULL in migration ?
PostgreSQL, Yii2.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
LAV45, 2017-03-23
@LAV45

$this->alterColumn('transactions', 'result', Schema::TYPE_INTEGER);
$this->alterColumn('transactions', 'result', 'SET NOT NULL');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question