Skip to content
Advertisement

Postgres a timestamp column constraint from NOT NULL to NULL

I’m trying to run a migration and make basically a column “modified” which is NOT NULL to be NULL. Like there is no need to have that constraint on it, I’ve run yoyo migrations and have the following output

Pointing to the timestamp ^

the table itself looks

I’ve tried to search the web, and found a few similar articles on stackoverflow but it didn’t help, so hopefully someone here can help.

Edit:

In yoyo migration

Advertisement

Answer

In Postgres, you can make a column nullable with DROP NOT NULL:

If you want to change the datatype at the same time, then:

Demo on DB Fiddle

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement