Report this

What is the reason for this report?

Enabled `moddatetime` extension on managed Postgres cluster

Posted on February 21, 2025

Hey there, I need to enable the moddatetime extension on my managed Postgres cluster but I can’t do it using doadmin and neither can I grant the admin user superuser privileges. How could I go about it?



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hey,

As far as I can see this is not part of the supported extensions based on the list here:

https://docs.digitalocean.com/products/databases/postgresql/details/supported-extensions/

But feel free to reach out to the DigitalOcean support team to see if they could by any chance enable it for you on their end:

https://www.digitalocean.com/support/

Hope that helps!

- Bobby.

Hey Bobby,

Thanks for that, yea I checked with DO support and seems like it is unsupported.

If anybody else runs into the same issue, I’ve resolved it by adding function which implements moddatetime if the extension is not available, see: https://stackoverflow.com/a/76092474

DO $SETUP_MODDATETIME$
BEGIN
  CREATE EXTENSION IF NOT EXISTS "moddatetime";
EXCEPTION WHEN INSUFFICIENT_PRIVILEGE THEN
  -- Unable to use moddatetime extension, so create a function instead
  CREATE OR REPLACE FUNCTION moddatetime() RETURNS trigger LANGUAGE plpgsql AS $moddatetime$
    DECLARE
      colname name;
    BEGIN
      IF (TG_NARGS = 1) THEN
        colname = TG_ARGV[0];
      ELSE
        RAISE EXCEPTION 'moddatetime(colname) requires one argument';
      END IF;

      RETURN json_populate_record(NEW, json_build_object(colname, NOW()));
    END;
  $moddatetime$;
END $SETUP_MODDATETIME$;

Heya,

The extension moddatetime should already be available! If that is not the case, you’ll need to reach to DigitalOcean support.

https://www.digitalocean.com/support/

If you have a ticket reference, post it here, we can try and speed things up for you.

Hope that helps! - KFSys.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.