Browse Source

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.
master
η (eta) 6 months ago
parent
commit
1e59c2a6c7
1 changed files with 18 additions and 0 deletions
  1. +18
    -0
      fixup_1.sql

+ 18
- 0
fixup_1.sql View File

@@ -0,0 +1,18 @@
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;

Loading…
Cancel
Save