Created
October 23, 2018 13:42
-
-
Save mykhailokrainik/a7e90d55a43fe0dbcff7be8c0d890757 to your computer and use it in GitHub Desktop.
PG add not null values column with array type
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ALTER TABLE users | |
ADD COLUMN positions INTEGER[] NULL; | |
UPDATE users SET positions = '{}'; | |
ALTER TABLE users | |
ALTER COLUMN positions SET NOT NULL; | |
-- +-----------------+--------------------------+----------------------------------------------------------+ | |
-- | Column | Type | Modifiers | | |
-- |-----------------+--------------------------+----------------------------------------------------------| | |
-- | ... | ... | ... | | |
-- | positions | integer[] | not null | | |
-- +-----------------+--------------------------+----------------------------------------------------------+ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment