Mercurial > hg > orthanc-databases
changeset 782:135bd5b3228c
fix upgrade
| author | Alain Mazy <am@orthanc.team> |
|---|---|
| date | Tue, 02 Dec 2025 15:44:14 +0100 |
| parents | 3a0ba14a99f5 |
| children | a6aa5a46899e |
| files | PostgreSQL/Plugins/SQL/Upgrades/Rev6ToRev10.sql |
| diffstat | 1 files changed, 40 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/PostgreSQL/Plugins/SQL/Upgrades/Rev6ToRev10.sql Mon Dec 01 15:10:22 2025 +0100 +++ b/PostgreSQL/Plugins/SQL/Upgrades/Rev6ToRev10.sql Tue Dec 02 15:44:14 2025 +0100 @@ -1,7 +1,43 @@ -- Adding a PK to these 2 table to allow pg_repack to process these tables, enabling reclaiming disk space and defragmenting the tables. -ALTER TABLE InvalidChildCounts ADD COLUMN pk BIGSERIAL PRIMARY KEY; -ALTER TABLE GlobalIntegersChanges ADD COLUMN pk BIGSERIAL PRIMARY KEY; +-- in rev 10, we need to modify the table InvalidChildCounts that is created in rev 4 but, +-- the table is actually created in PrepareDatabase.sql that will be run after the upgrade script +-- hence this check before executin the ALTER TABLE. +DO $$ +BEGIN + IF EXISTS ( + SELECT 1 + FROM information_schema.tables + WHERE table_schema = 'public' + AND table_name = 'invalidchildcounts' + ) THEN + ALTER TABLE InvalidChildCounts ADD COLUMN pk BIGSERIAL PRIMARY KEY; + END IF; +END $$; --- Adding the queues timeout -ALTER TABLE Queues ADD COLUMN reservedUntil BIGINT DEFAULT NULL; \ No newline at end of file +-- same for GlobalIntegersChanges table that is created in rev2: +DO $$ +BEGIN + IF EXISTS ( + SELECT 1 + FROM information_schema.tables + WHERE table_schema = 'public' + AND table_name = 'globalintegerschanges' + ) THEN + ALTER TABLE GlobalIntegersChanges ADD COLUMN pk BIGSERIAL PRIMARY KEY; + END IF; +END $$; + + +-- Adding the queues timeout (Queues table was created in rev5) +DO $$ +BEGIN + IF EXISTS ( + SELECT 1 + FROM information_schema.tables + WHERE table_schema = 'public' + AND table_name = 'queues' + ) THEN + ALTER TABLE Queues ADD COLUMN reservedUntil BIGINT DEFAULT NULL; + END IF; +END $$;
