DO $$DECLARE this_version CONSTANT varchar := '00.02.000'; BEGIN PERFORM * FROM "DBVersion" WHERE version = this_version; IF FOUND THEN RETURN; END IF; DROP TABLE public."DatasetDataRepository"; DROP TABLE public."DatasetExternalDataset"; DROP TABLE public."DatasetRegistry"; DROP TABLE public."DatasetService"; DROP TABLE public."Dataset"; DROP TABLE public."DMPDatasetProfile"; DROP TABLE public."DMPOrganisation"; DROP TABLE public."DMPResearcher"; DROP TABLE public."UserDMP"; DROP TABLE public."Invitation"; DROP TABLE public."DMP"; DROP TABLE public."DoiFunder"; DROP TABLE public."DataRepository"; DROP TABLE public."ExternalDataset"; DROP TABLE public."Project"; DROP TABLE public."Funder"; DROP TABLE public."Grant"; DROP TABLE public."Organisation"; DROP TABLE public."Registry"; DROP TABLE public."Researcher"; DROP TABLE public."Service"; DROP TABLE public."Content"; DROP TABLE public."Credential"; DROP TABLE public."EmailConfirmation"; DROP TABLE public."FileUpload"; DROP TABLE public."NotificationLegacy"; DROP TABLE public."UserAssociation"; DROP TABLE public."UserToken"; DROP TABLE public."UserInfo"; INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.02.000', '2024-06-26 12:00:00.000000+02', now(), 'Remove unused tables.'); END$$;