Skip to content

Commit

Permalink
Fix minor SQL schema inconsistencies
Browse files Browse the repository at this point in the history
  • Loading branch information
nosnilmot committed Jan 19, 2023
1 parent e32d582 commit 2c08457
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions sql/lite.new.sql
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ CREATE TABLE push_session (
);

CREATE UNIQUE INDEX i_push_session_susn ON push_session (server_host, username, service, node);
CREATE INDEX i_push_session_sh_username_timestamp ON push_session (server_host, username, timestamp);

CREATE TABLE mix_channel (
channel text NOT NULL,
Expand Down
2 changes: 1 addition & 1 deletion sql/mssql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ CREATE TABLE [dbo].[push_session] (
CREATE UNIQUE CLUSTERED INDEX [i_push_usn] ON [push_session] (username, service, node)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON);

CREATE UNIQUE INDEX [i_push_ut] ON [push_session] (username, timestamp)
CREATE INDEX [i_push_ut] ON [push_session] (username, timestamp)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON);

CREATE TABLE [dbo].[mix_channel] (
Expand Down
1 change: 1 addition & 0 deletions sql/mysql.new.sql
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ CREATE TABLE push_session (
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

CREATE UNIQUE INDEX i_push_session_susn ON push_session (server_host(191), username(191), service(191), node(191));
CREATE INDEX i_push_session_sh_username_timestamp ON push_session (server_host, username(191), timestamp);

CREATE TABLE mix_channel (
channel text NOT NULL,
Expand Down
4 changes: 2 additions & 2 deletions sql/mysql.old-to-new.sql
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ BEGIN
ALTER TABLE `push_session` ALTER COLUMN `server_host` DROP DEFAULT;
ALTER TABLE `push_session` ADD PRIMARY KEY (`server_host`, `username`(191), `timestamp`);
ALTER TABLE `push_session` ADD UNIQUE INDEX `i_push_session_susn` (`server_host`, `username`(191), `service`(191), `node`(191));
ALTER TABLE `push_session` ADD INDEX `i_push_session_sh_username_timestamp` (`server_host`, `username`(191), `timestamp`);
ALTER TABLE `roster_version` DROP PRIMARY KEY;
ALTER TABLE `roster_version` ADD COLUMN `server_host` VARCHAR (191) COLLATE `utf8mb4_unicode_ci` NOT NULL DEFAULT @DEFAULT_HOST AFTER `username`;
ALTER TABLE `roster_version` ALTER COLUMN `server_host` DROP DEFAULT;
Expand Down Expand Up @@ -73,10 +74,10 @@ BEGIN
ALTER TABLE `last` ADD COLUMN `server_host` VARCHAR (191) COLLATE `utf8mb4_unicode_ci` NOT NULL DEFAULT @DEFAULT_HOST AFTER `username`;
ALTER TABLE `last` ALTER COLUMN `server_host` DROP DEFAULT;
ALTER TABLE `last` ADD PRIMARY KEY (`server_host`, `username`);
ALTER TABLE `sr_group` DROP INDEX `i_sr_group_name`;
ALTER TABLE `sr_group` ADD COLUMN `server_host` VARCHAR (191) COLLATE `utf8mb4_unicode_ci` NOT NULL DEFAULT @DEFAULT_HOST AFTER `name`;
ALTER TABLE `sr_group` ALTER COLUMN `server_host` DROP DEFAULT;
ALTER TABLE `sr_group` ADD UNIQUE INDEX `i_sr_group_sh_name` (`server_host`, `name`);
ALTER TABLE `sr_group` ADD PRIMARY KEY (`server_host`, `name`);
ALTER TABLE `muc_registered` ADD COLUMN `server_host` VARCHAR (191) COLLATE `utf8mb4_unicode_ci` NOT NULL DEFAULT @DEFAULT_HOST AFTER `host`;
ALTER TABLE `muc_registered` ALTER COLUMN `server_host` DROP DEFAULT;
ALTER TABLE `sm` DROP INDEX `i_node`;
Expand All @@ -99,7 +100,6 @@ BEGIN
ALTER TABLE `sr_user` ALTER COLUMN `server_host` DROP DEFAULT;
ALTER TABLE `sr_user` ADD UNIQUE INDEX `i_sr_user_sh_jid_group` (`server_host`, `jid`, `grp`);
ALTER TABLE `sr_user` ADD INDEX `i_sr_user_sh_grp` (`server_host`, `grp`);
ALTER TABLE `sr_user` ADD PRIMARY KEY (`server_host`, `jid`, `grp`);
ALTER TABLE `muc_online_users` ADD COLUMN `server_host` VARCHAR (191) COLLATE `utf8mb4_unicode_ci` NOT NULL DEFAULT @DEFAULT_HOST AFTER `host`;
ALTER TABLE `muc_online_users` ALTER COLUMN `server_host` DROP DEFAULT;
ALTER TABLE `vcard` DROP PRIMARY KEY;
Expand Down
4 changes: 4 additions & 0 deletions sql/pg.new.sql
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@
-- ALTER TABLE rostergroups ALTER COLUMN server_host DROP DEFAULT;

-- ALTER TABLE sr_group ADD COLUMN server_host text NOT NULL DEFAULT '<HOST>';
-- DROP INDEX i_sr_group_name;
-- ALTER TABLE sr_group ADD PRIMARY KEY (server_host, name);
-- CREATE UNIQUE INDEX i_sr_group_sh_name ON sr_group USING btree (server_host, name);
-- ALTER TABLE sr_group ALTER COLUMN server_host DROP DEFAULT;

-- ALTER TABLE sr_user ADD COLUMN server_host text NOT NULL DEFAULT '<HOST>';
Expand Down Expand Up @@ -153,6 +155,7 @@
-- DROP INDEX i_push_ut;
-- ALTER TABLE push_session ADD PRIMARY KEY (server_host, username, timestamp);
-- CREATE UNIQUE INDEX i_push_session_susn ON push_session USING btree (server_host, username, service, node);
-- CREATE INDEX i_push_session_sh_username_timestamp ON push_session USING btree (server_host, username, timestamp);
-- ALTER TABLE push_session ALTER COLUMN server_host DROP DEFAULT;

-- ALTER TABLE mix_pam ADD COLUMN server_host text NOT NULL DEFAULT '<HOST>';
Expand Down Expand Up @@ -583,6 +586,7 @@ CREATE TABLE push_session (
);

CREATE UNIQUE INDEX i_push_session_susn ON push_session USING btree (server_host, username, service, node);
CREATE INDEX i_push_session_sh_username_timestamp ON push_session USING btree (server_host, username, timestamp);

CREATE TABLE mix_channel (
channel text NOT NULL,
Expand Down
2 changes: 1 addition & 1 deletion sql/pg.sql
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ CREATE TABLE push_session (
);

CREATE UNIQUE INDEX i_push_usn ON push_session USING btree (username, service, node);
CREATE UNIQUE INDEX i_push_ut ON push_session USING btree (username, timestamp);
CREATE INDEX i_push_ut ON push_session USING btree (username, timestamp);

CREATE TABLE mix_channel (
channel text NOT NULL,
Expand Down

0 comments on commit 2c08457

Please sign in to comment.