whatsxmpp/fixup_1.sql
eta 1e59c2a6c7 add fixup_1.sql, which corrects the UNIQUE error on user_contacts
- The user_contacts table contained an incorrect UNIQUE constraint
  on wa_jid that meant only one user of the bridge could have any
  given whatsapp user in their contacts.
- This is fixed in fixup_1.sql, which should be applied over schema.sql.
2020-07-23 08:08:44 +01:00

19 lines
552 B
PL/PgSQL

BEGIN;
CREATE TABLE new_user_contacts (
id INTEGER PRIMARY KEY,
user_id INT NOT NULL REFERENCES users,
wa_jid VARCHAR NOT NULL,
subscription_state VARCHAR NOT NULL DEFAULT 'none',
avatar_url VARCHAR,
name VARCHAR,
notify VARCHAR,
status VARCHAR,
UNIQUE(user_id, wa_jid)
);
INSERT INTO new_user_contacts SELECT * FROM user_contacts;
DROP TABLE user_contacts;
ALTER TABLE new_user_contacts RENAME TO user_contacts;
CREATE INDEX user_contacts_idx ON user_contacts (user_id, wa_jid);
COMMIT;