P
P
poimanoo2018-09-04 07:57:59
PostgreSQL
poimanoo, 2018-09-04 07:57:59

How to set string data type for Postgresql in yii2 without character limit?

Hello. If I create a table through migrations specifying the string() data type, then Postgres creates a column with the character varying(255) type, and I need it to be just character varying without a length limit. How can this be achieved? You can, of course, write text() instead of string(), but then the column type will be exactly text, and I need to create character varying. Thank you.

public function safeUp()
    {
        $this->createTable('ad', [
            'id' => $this->primaryKey(),
            'name' => $this->string()->notNull(),
            'created_at' => $this->integer()->notNull(),
            'updated_at' => $this->integer()->notNull()
        ]);
    }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Decadal, 2018-09-04
@poimanoo

Set string to just 'varchar'
For postgres, these are strings of any length
"name"=> "varchar not null"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question