pgsql-update.sql 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. -- 19.02
  2. CREATE TABLE mix_channel (
  3. channel text NOT NULL,
  4. service text NOT NULL,
  5. username text NOT NULL,
  6. domain text NOT NULL,
  7. jid text NOT NULL,
  8. hidden boolean NOT NULL,
  9. hmac_key text NOT NULL,
  10. created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
  11. );
  12. CREATE UNIQUE INDEX i_mix_channel ON mix_channel (channel, service);
  13. CREATE INDEX i_mix_channel_serv ON mix_channel (service);
  14. CREATE TABLE mix_participant (
  15. channel text NOT NULL,
  16. service text NOT NULL,
  17. username text NOT NULL,
  18. domain text NOT NULL,
  19. jid text NOT NULL,
  20. id text NOT NULL,
  21. nick text NOT NULL,
  22. created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
  23. );
  24. CREATE UNIQUE INDEX i_mix_participant ON mix_participant (channel, service, username, domain);
  25. CREATE INDEX i_mix_participant_chan_serv ON mix_participant (channel, service);
  26. CREATE TABLE mix_subscription (
  27. channel text NOT NULL,
  28. service text NOT NULL,
  29. username text NOT NULL,
  30. domain text NOT NULL,
  31. node text NOT NULL,
  32. jid text NOT NULL
  33. );
  34. CREATE UNIQUE INDEX i_mix_subscription ON mix_subscription (channel, service, username, domain, node);
  35. CREATE INDEX i_mix_subscription_chan_serv_ud ON mix_subscription (channel, service, username, domain);
  36. CREATE INDEX i_mix_subscription_chan_serv_node ON mix_subscription (channel, service, node);
  37. CREATE INDEX i_mix_subscription_chan_serv ON mix_subscription (channel, service);
  38. CREATE TABLE mix_pam (
  39. username text NOT NULL,
  40. channel text NOT NULL,
  41. service text NOT NULL,
  42. id text NOT NULL,
  43. created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
  44. );
  45. CREATE UNIQUE INDEX i_mix_pam ON mix_pam (username, channel, service);
  46. CREATE INDEX i_mix_pam_us ON mix_pam (username);
  47. -- 20.01
  48. CREATE TABLE oauth_client (
  49. client_id text PRIMARY KEY,
  50. client_name text NOT NULL,
  51. grant_type text NOT NULL,
  52. options text NOT NULL
  53. );
  54. -- 21.07
  55. CREATE UNIQUE INDEX i_sr_group_name ON sr_group USING btree (name);
  56. -- 21.12
  57. -- If you migrated your PostgreSQL database from old to new schema using
  58. -- previous ejabberd versions, your database may be missing the migration
  59. -- steps for the push_session table. You can update it now with:
  60. ALTER TABLE push_session ADD COLUMN server_host text NOT NULL DEFAULT '<HOST>';
  61. DROP INDEX i_push_usn;
  62. DROP INDEX i_push_ut;
  63. ALTER TABLE push_session ADD PRIMARY KEY (server_host, username, timestamp);
  64. CREATE UNIQUE INDEX i_push_session_susn ON push_session USING btree (server_host, username, service, node);
  65. -- In the PostgreSQL new schema, the primary key for the vcard_search table
  66. -- was wrong. How to update an existing database:
  67. ALTER TABLE vcard_search DROP CONSTRAINT vcard_search_pkey;
  68. ALTER TABLE vcard_search ADD PRIMARY KEY (server_host, lusername);