Delete an extension from the PostgreSQL database

Remove extension records and related data directly from the PostgreSQL database when the administrator API is not available or when you need to clean up specific data. If the extension uses local storage, you must also remove its files from the Open VSX server pod.

Prerequisites
  • You have access to the cluster where the Open VSX registry is deployed in the openvsx namespace.

  • You have the kubectl tool installed.

  • You know the namespace name and extension name that you want to delete.

Procedure
  1. Open a command prompt in the PostgreSQL pod and connect to the database:

    export POSTGRESQL_POD_NAME=$(kubectl get pods -n openvsx \
       -o jsonpath="{.items[*].metadata.name}" | tr ' ' '\n' | grep '^postgresql' | head -n 1)
    kubectl exec -it $POSTGRESQL_POD_NAME -n openvsx -- /bin/bash

    Inside the pod, run psql:

    psql

    At the postgres=# prompt, connect to the database:

    \c openvsx

    You are now connected to the openvsx database as the postgres user.

  2. Find the namespace ID and extension ID:

    Identify the extension publisher. Replace <namespace_name> with the actual publisher name:

    SELECT id, name FROM namespace WHERE name = '<namespace_name>';

    Identify the extension ID. Replace <namespace_id> and <extension_name> with the values from the previous query:

    SELECT id, name, namespace_id FROM extension WHERE namespace_id = <namespace_id> AND name = '<extension_name>';

    Note the ID of the extension to use as <extension_id> in the next steps.

  3. Optional: Preview extension versions and file resources:

    Preview the versions:

    SELECT id, version, pre_release, semver_pre_release, semver_is_pre_release FROM extension_version WHERE extension_id = <extension_id> ORDER BY timestamp DESC;

    Preview the file resources:

    SELECT id, name, type, storage_type FROM file_resource WHERE extension_id = <extension_id> ORDER BY id;

    If the storage_type value is local, you must also remove the extension files from the file system on the Open VSX server pod.

  4. Delete the extension from the database:

    Run the following commands in a single transaction. Replace <extension_id> with the extension ID from step 2.

    BEGIN;
    -- 1. Delete all file resources for the extension
    DELETE FROM file_resource WHERE extension_id = <extension_id>;
    -- 2. Delete all extension reviews
    DELETE FROM extension_review WHERE extension_id = <extension_id>;
    -- 3. Delete all versions of the extension
    DELETE FROM extension_version WHERE extension_id = <extension_id>;
    -- 4. Delete the extension entry itself
    DELETE FROM extension WHERE id = <extension_id>;
    COMMIT;

    Run these commands in order within one transaction. Do not skip the COMMIT command, or the system does not apply the changes.

  5. If the extension used local storage, remove the extension files from the Open VSX server pod:

    Get the Open VSX server pod name:

    export OPENVSX_POD_NAME=$(kubectl get pods -n openvsx -o jsonpath="{.items[*].metadata.name}" | tr ' ' '\n' | grep '^openvsx-server' | head -n 1)

    Delete the extension folder:

    kubectl exec -it $OPENVSX_POD_NAME -n openvsx -- /bin/bash -c "rm -rf /tmp/extensions/<publisher>/<extension>"
Verification
  • Refresh your Open VSX registry and verify that the extension no longer appears in the gallery.