T
T
TANK_IST2017-06-21 23:21:50
PostgreSQL
TANK_IST, 2017-06-21 23:21:50

Why does doctrine 2 (postgresql) fail to execute DEFAULT NULL when migrating?

Basically there is a column

/**
     * @ORM\Column(type="string", nullable=true, options={"default": "slug"})
     */
    protected $slug = null;

By executing php app/console doctrine:migrations:diff
in up the update line is:
ALTER TABLE blog ADD slug VARCHAR(255) DEFAULT NULL

But when I do php app/console doctrine:migrations:migrateI get
[PDOException]                                                                     
  SQLSTATE[23502]: Not null violation: 7 ERROR:  column "slug" contains null values

Please tell me why. Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
gill-sama, 2017-06-22
@gill-sama

You're putting a constraint on a column that doesn't traverse it. i.e. you already have null values ​​in "slug". You need to change them to something else and try again.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question