Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync old-to-new schema script with reality #3790

Merged
merged 1 commit into from
Mar 8, 2022

Conversation

nosnilmot
Copy link
Contributor

Update the update_sql function to match current "new" sql schema

"XRevan86" pointed out in ejabberd@conference.process-one.net that i_push_session_susn should have been created as a unique index, and on closer inspection there are a number of other discrepancies between the update function and the actual schema

Users who have previously updated from old to new schema using this function would need to manually perform the following to correct their schema:

ALTER TABLE archive DROP CONSTRAINT i_archive_sh_peer;
ALTER TABLE archive DROP CONSTRAINT i_archive_sh_bare_peer;
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);

DROP TABLE carboncopy;

ALTER TABLE push_session DROP CONSTRAINT i_push_session_susn;
CREATE UNIQUE INDEX i_push_session_susn ON push_session USING btree (server_host, username, service, node);

ALTER TABLE mix_pam DROP CONSTRAINT i_mix_pam;
ALTER TABLE mix_pam DROP CONSTRAINT i_mix_pam_us;
CREATE UNIQUE INDEX i_mix_pam ON mix_pam (username, server_host, channel, service);
CREATE INDEX i_mix_pam_us ON mix_pam (username, server_host);

ALTER TABLE route DROP CONSTRAINT i_route;
CREATE UNIQUE INDEX i_route ON route USING btree (domain, server_host, node, pid);

ALTER TABLE mqtt_pub DROP CONSTRAINT i_mqtt_topic;
CREATE UNIQUE INDEX i_mqtt_topic_server ON mqtt_pub (topic, server_host);

Update the update_sql function to match current "new" sql schema
@prefiks
Copy link
Member

prefiks commented Mar 8, 2022

Looks fine, let's merge it

@prefiks prefiks merged commit dca49f5 into processone:master Mar 8, 2022
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.009%) to 34.054% when pulling 3324254 on nosnilmot:fix-pg-sql-migrate into 3520869 on processone:master.

@Neustradamus
Copy link
Contributor

It will be nice to see if all are sync (without forgetting):

@badlop badlop added this to the ejabberd 22.xx milestone Mar 15, 2022
@nosnilmot nosnilmot deleted the fix-pg-sql-migrate branch September 13, 2022 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants