There is a problem in the comments section of the NextCloud

You must fix that table, there are no defaults defined.

This should fix it:

BEGIN;

-- Change column `id` to bigint and set a sequence as the default
ALTER TABLE oc_comments
    ALTER COLUMN id TYPE bigint,
    ALTER COLUMN id SET DEFAULT nextval('oc_comments_id_seq'::regclass);

-- Change `parent_id` to bigint and set the default value to 0
ALTER TABLE oc_comments
    ALTER COLUMN parent_id TYPE bigint,
    ALTER COLUMN parent_id SET DEFAULT 0;

-- Change `topmost_parent_id` to bigint and set the default value to 0
ALTER TABLE oc_comments
    ALTER COLUMN topmost_parent_id TYPE bigint,
    ALTER COLUMN topmost_parent_id SET DEFAULT 0;

-- Change `children_count` to integer and set the default value to 0
ALTER TABLE oc_comments
    ALTER COLUMN children_count TYPE integer,
    ALTER COLUMN children_count SET DEFAULT 0;

-- Set default value for `actor_type` to an empty string
ALTER TABLE oc_comments
    ALTER COLUMN actor_type SET DEFAULT ''::character varying;

-- Set default value for `actor_id` to an empty string
ALTER TABLE oc_comments
    ALTER COLUMN actor_id SET DEFAULT ''::character varying;

-- Set default value for `verb` to NULL
ALTER TABLE oc_comments
    ALTER COLUMN verb SET DEFAULT NULL::character varying;

-- Change `creation_timestamp` and `latest_child_timestamp` to timestamp(0) without time zone and set the default to NULL
ALTER TABLE oc_comments
    ALTER COLUMN creation_timestamp TYPE timestamp(0) without time zone,
    ALTER COLUMN creation_timestamp SET DEFAULT NULL::timestamp without time zone,
    ALTER COLUMN latest_child_timestamp TYPE timestamp(0) without time zone,
    ALTER COLUMN latest_child_timestamp SET DEFAULT NULL::timestamp without time zone;

-- Set default value for `object_type` to an empty string
ALTER TABLE oc_comments
    ALTER COLUMN object_type SET DEFAULT ''::character varying;

-- Set default value for `object_id` to an empty string
ALTER TABLE oc_comments
    ALTER COLUMN object_id SET DEFAULT ''::character varying;

-- Set default value for `reference_id` to NULL
ALTER TABLE oc_comments
    ALTER COLUMN reference_id SET DEFAULT NULL::character varying;

-- Set default value for `reactions` to NULL
ALTER TABLE oc_comments
    ALTER COLUMN reactions SET DEFAULT NULL::character varying;

-- Set default value for `expire_date` to NULL
ALTER TABLE oc_comments
    ALTER COLUMN expire_date SET DEFAULT NULL::timestamp without time zone;

-- Set default value for `meta_data` to an empty text
ALTER TABLE oc_comments
    ALTER COLUMN meta_data SET DEFAULT ''::text;

COMMIT;

No guarantee, I did not test it.


Much and good luck,
ernolf

4 Likes