Mercurial > libervia-pubsub
comparison db/libervia_pubsub_update_8_9.sql @ 466:0d38c3529972
psql: schema update (9) to add `roster` table
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 15 Oct 2021 13:40:59 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
465:9af0ef2c145c | 466:0d38c3529972 |
---|---|
1 -- we check version of the database before doing anything | |
2 -- and stop execution if not good | |
3 \set ON_ERROR_STOP | |
4 DO $$ | |
5 DECLARE ver text; | |
6 BEGIN | |
7 SELECT value INTO ver FROM metadata WHERE key='version'; | |
8 IF NOT FOUND OR ver!='8' THEN | |
9 RAISE EXCEPTION 'This update file needs to be applied on database schema version 8, you use version %',ver; | |
10 END IF; | |
11 END$$; | |
12 \unset ON_ERROR_STOP | |
13 -- end of version check | |
14 | |
15 /* new "roster" table */ | |
16 CREATE TABLE roster ( | |
17 roster_id serial PRIMARY KEY, | |
18 jid text NOT NULL UNIQUE, | |
19 version text, | |
20 updated timestamp with time zone NOT NULL, | |
21 roster xml NOT NULL | |
22 ); | |
23 | |
24 UPDATE metadata SET value='9' WHERE key='version'; |