diff --git a/sql/lite.new.sql b/sql/lite.new.sql index f48a393a048..b5ec2098f88 100644 --- a/sql/lite.new.sql +++ b/sql/lite.new.sql @@ -106,6 +106,7 @@ CREATE TABLE archive ( id INTEGER PRIMARY KEY AUTOINCREMENT, kind text, nick text, + origin_id text, created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ); @@ -113,6 +114,11 @@ CREATE INDEX i_archive_sh_username_timestamp ON archive (server_host, username, CREATE INDEX i_archive_sh_username_peer ON archive (server_host, username, peer); CREATE INDEX i_archive_sh_username_bare_peer ON archive (server_host, username, bare_peer); CREATE INDEX i_archive_sh_timestamp ON archive (server_host, timestamp); +CREATE INDEX i_archive_sh_username_origin_id ON archive (server_host, username, origin_id); + +-- To update 'archive' from ejabberd <= 23.10: +-- ALTER TABLE archive ADD COLUMN origin_id text NOT NULL DEFAULT ''; +-- CREATE INDEX i_archive_sh_username_origin_id ON archive (server_host, username, origin_id); CREATE TABLE archive_prefs ( username text NOT NULL, diff --git a/sql/lite.sql b/sql/lite.sql index a920a6cd5b2..67067480da2 100644 --- a/sql/lite.sql +++ b/sql/lite.sql @@ -94,6 +94,7 @@ CREATE TABLE archive ( id INTEGER PRIMARY KEY AUTOINCREMENT, kind text, nick text, + origin_id text, created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ); @@ -101,6 +102,11 @@ CREATE INDEX i_username_timestamp ON archive(username, timestamp); CREATE INDEX i_archive_username_peer ON archive (username, peer); CREATE INDEX i_archive_username_bare_peer ON archive (username, bare_peer); CREATE INDEX i_timestamp ON archive(timestamp); +CREATE INDEX i_archive_username_origin_id ON archive (username, origin_id); + +-- To update 'archive' from ejabberd <= 23.10: +-- ALTER TABLE archive ADD COLUMN origin_id text NOT NULL DEFAULT ''; +-- CREATE INDEX i_archive_username_origin_id ON archive (username, origin_id); CREATE TABLE archive_prefs ( username text NOT NULL PRIMARY KEY, diff --git a/sql/mssql.new.sql b/sql/mssql.new.sql index c78e28ea265..2227d0a6b91 100644 --- a/sql/mssql.new.sql +++ b/sql/mssql.new.sql @@ -32,6 +32,7 @@ CREATE TABLE [dbo].[archive] ( [id] [bigint] IDENTITY(1,1) NOT NULL, [kind] [varchar] (10) NULL, [nick] [varchar] (250) NULL, + [origin_id] [varchar] (250) NOT NULL, [created_at] [datetime] NOT NULL DEFAULT GETDATE(), CONSTRAINT [archive_PK] PRIMARY KEY CLUSTERED ( @@ -51,6 +52,9 @@ WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW CREATE INDEX [archive_sh_timestamp] ON [archive] (server_host, timestamp) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON); +CREATE INDEX [archive_sh_username_origin_id] ON [archive] (server_host, username, origin_id) +WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON); + CREATE TABLE [dbo].[archive_prefs] ( [username] [varchar] (250) NOT NULL, [server_host] [varchar] (250) NOT NULL, diff --git a/sql/mssql.sql b/sql/mssql.sql index cf2f8b0400c..93b8c6ed583 100644 --- a/sql/mssql.sql +++ b/sql/mssql.sql @@ -31,6 +31,7 @@ CREATE TABLE [dbo].[archive] ( [id] [bigint] IDENTITY(1,1) NOT NULL, [kind] [varchar] (10) NULL, [nick] [varchar] (250) NULL, + [origin_id] [varchar] (250) NOT NULL, [created_at] [datetime] NOT NULL DEFAULT GETDATE(), CONSTRAINT [archive_PK] PRIMARY KEY CLUSTERED ( @@ -50,6 +51,9 @@ WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW CREATE INDEX [archive_timestamp] ON [archive] (timestamp) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON); +CREATE INDEX [archive_username_origin_id] ON [archive] (username, origin_id) +WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON); + CREATE TABLE [dbo].[archive_prefs] ( [username] [varchar] (250) NOT NULL, [def] [text] NOT NULL, diff --git a/sql/mysql.new.sql b/sql/mysql.new.sql index 6254282d5c1..8df583cf79e 100644 --- a/sql/mysql.new.sql +++ b/sql/mysql.new.sql @@ -110,6 +110,7 @@ CREATE TABLE archive ( id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE, kind varchar(10), nick varchar(191), + origin_id varchar(191), created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; @@ -118,6 +119,12 @@ CREATE INDEX i_archive_sh_username_timestamp USING BTREE ON archive(server_host( CREATE INDEX i_archive_sh_username_peer USING BTREE ON archive(server_host(191), username(191), peer(191)); CREATE INDEX i_archive_sh_username_bare_peer USING BTREE ON archive(server_host(191), username(191), bare_peer(191)); CREATE INDEX i_archive_sh_timestamp USING BTREE ON archive(server_host(191), timestamp); +CREATE INDEX i_archive_sh_username_origin_id USING BTREE ON archive(server_host(191), username(191), origin_id(191)); + +-- To update 'archive' from ejabberd <= 23.10: +-- ALTER TABLE archive ADD COLUMN origin_id text NOT NULL DEFAULT ''; +-- ALTER TABLE archive ALTER COLUMN origin_id DROP DEFAULT; +-- CREATE INDEX i_archive_sh_username_origin_id USING BTREE ON archive(server_host(191), username(191), origin_id(191)); CREATE TABLE archive_prefs ( username varchar(191) NOT NULL, diff --git a/sql/mysql.sql b/sql/mysql.sql index af93302ddbb..1f97039b471 100644 --- a/sql/mysql.sql +++ b/sql/mysql.sql @@ -98,6 +98,7 @@ CREATE TABLE archive ( id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE, kind varchar(10), nick varchar(191), + origin_id varchar(191), created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; @@ -106,6 +107,12 @@ CREATE INDEX i_username_timestamp USING BTREE ON archive(username(191), timestam CREATE INDEX i_username_peer USING BTREE ON archive(username(191), peer(191)); CREATE INDEX i_username_bare_peer USING BTREE ON archive(username(191), bare_peer(191)); CREATE INDEX i_timestamp USING BTREE ON archive(timestamp); +CREATE INDEX i_archive_username_origin_id USING BTREE ON archive(username(191), origin_id(191)); + +-- To update 'archive' from ejabberd <= 23.10: +-- ALTER TABLE archive ADD COLUMN origin_id text NOT NULL DEFAULT ''; +-- ALTER TABLE archive ALTER COLUMN origin_id DROP DEFAULT; +-- CREATE INDEX i_archive_username_origin_id USING BTREE ON archive(username(191), origin_id(191)); CREATE TABLE archive_prefs ( username varchar(191) NOT NULL PRIMARY KEY, diff --git a/sql/pg.new.sql b/sql/pg.new.sql index 6a13ad6f39a..bfb01723e6f 100644 --- a/sql/pg.new.sql +++ b/sql/pg.new.sql @@ -261,6 +261,7 @@ CREATE TABLE archive ( id BIGSERIAL, kind text, nick text, + origin_id text, created_at TIMESTAMP NOT NULL DEFAULT now() ); @@ -268,6 +269,12 @@ CREATE INDEX i_archive_sh_username_timestamp ON archive USING btree (server_host CREATE INDEX i_archive_sh_username_peer ON archive USING btree (server_host, username, peer); CREATE INDEX i_archive_sh_username_bare_peer ON archive USING btree (server_host, username, bare_peer); CREATE INDEX i_archive_sh_timestamp ON archive USING btree (server_host, timestamp); +CREATE INDEX i_archive_sh_username_origin_id ON archive USING btree (server_host, username, origin_id); + +-- To update 'archive' from ejabberd <= 23.10: +-- ALTER TABLE archive ADD COLUMN origin_id text NOT NULL DEFAULT ''; +-- ALTER TABLE archive ALTER COLUMN origin_id DROP DEFAULT; +-- CREATE INDEX i_archive_sh_username_origin_id ON archive USING btree (server_host, username, origin_id); CREATE TABLE archive_prefs ( username text NOT NULL, diff --git a/sql/pg.sql b/sql/pg.sql index 813e690ddd2..3c54466c8de 100644 --- a/sql/pg.sql +++ b/sql/pg.sql @@ -98,6 +98,7 @@ CREATE TABLE archive ( id BIGSERIAL, kind text, nick text, + origin_id text, created_at TIMESTAMP NOT NULL DEFAULT now() ); @@ -105,6 +106,12 @@ CREATE INDEX i_username_timestamp ON archive USING btree (username, timestamp); CREATE INDEX i_username_peer ON archive USING btree (username, peer); CREATE INDEX i_username_bare_peer ON archive USING btree (username, bare_peer); CREATE INDEX i_timestamp ON archive USING btree (timestamp); +CREATE INDEX i_archive_username_origin_id ON archive USING btree (username, origin_id); + +-- To update 'archive' from ejabberd <= 23.10: +-- ALTER TABLE archive ADD COLUMN origin_id text NOT NULL DEFAULT ''; +-- ALTER TABLE archive ALTER COLUMN origin_id DROP DEFAULT; +-- CREATE INDEX i_archive_username_origin_id ON archive USING btree (username, origin_id); CREATE TABLE archive_prefs ( username text NOT NULL PRIMARY KEY,