pgsql-update.sql 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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);
  69. -- 22.05
  70. CREATE INDEX i_muc_room_host_created_at ON muc_room USING btree (host, created_at);
  71. CREATE INDEX i_muc_room_subscribers_jid ON muc_room_subscribers USING btree (jid);
  72. ALTER TABLE archive DROP CONSTRAINT i_archive_sh_peer;
  73. ALTER TABLE archive DROP CONSTRAINT i_archive_sh_bare_peer;
  74. CREATE INDEX i_archive_sh_username_peer ON archive USING btree (server_host, username, peer);
  75. CREATE INDEX i_archive_sh_username_bare_peer ON archive USING btree (server_host, username, bare_peer);
  76. DROP TABLE carboncopy;
  77. ALTER TABLE push_session DROP CONSTRAINT i_push_session_susn;
  78. CREATE UNIQUE INDEX i_push_session_susn ON push_session USING btree (server_host, username, service, node);
  79. ALTER TABLE mix_pam DROP CONSTRAINT i_mix_pam;
  80. ALTER TABLE mix_pam DROP CONSTRAINT i_mix_pam_us;
  81. CREATE UNIQUE INDEX i_mix_pam ON mix_pam (username, server_host, channel, service);
  82. CREATE INDEX i_mix_pam_us ON mix_pam (username, server_host);
  83. ALTER TABLE route DROP CONSTRAINT i_route;
  84. CREATE UNIQUE INDEX i_route ON route USING btree (domain, server_host, node, pid);
  85. ALTER TABLE mqtt_pub DROP CONSTRAINT i_mqtt_topic;
  86. CREATE UNIQUE INDEX i_mqtt_topic_server ON mqtt_pub (topic, server_host);
  87. -- 23.04
  88. ALTER TABLE vcard_search DROP CONSTRAINT vcard_search_pkey;
  89. ALTER TABLE vcard_search ADD PRIMARY KEY (server_host, lusername);
  90. ALTER TABLE archive ALTER COLUMN id TYPE BIGINT;
  91. ALTER TABLE privacy_list ALTER COLUMN id TYPE BIGINT;
  92. ALTER TABLE pubsub_node ALTER COLUMN nodeid TYPE BIGINT;
  93. ALTER TABLE pubsub_state ALTER COLUMN stateid TYPE BIGINT;
  94. ALTER TABLE spool ALTER COLUMN seq TYPE BIGINT;
  95. DROP INDEX i_rosteru_username;
  96. DROP INDEX i_sr_user_jid;
  97. DROP INDEX i_privacy_list_username;
  98. DROP INDEX i_private_storage_username;
  99. DROP INDEX i_muc_online_users_us;
  100. DROP INDEX i_route_domain;
  101. DROP INDEX i_mix_participant_chan_serv;
  102. DROP INDEX i_mix_subscription_chan_serv_ud;
  103. DROP INDEX i_mix_subscription_chan_serv;
  104. DROP INDEX i_mix_pam_us;
  105. DROP INDEX i_rosteru_sh_username;
  106. DROP INDEX i_sr_user_sh_jid;
  107. DROP INDEX i_privacy_list_sh_username;
  108. DROP INDEX i_private_storage_sh_username;
  109. DROP INDEX i_muc_online_users_us;
  110. DROP INDEX i_route_domain;
  111. DROP INDEX i_mix_participant_chan_serv;
  112. DROP INDEX i_mix_subscription_chan_serv_ud;
  113. DROP INDEX i_mix_subscription_chan_serv;
  114. DROP INDEX i_mix_pam_us;
  115. CREATE INDEX i_push_session_sh_username_timestamp ON push_session USING btree (server_host, username, timestamp);