Merge ~ines-almeida/launchpad:db-add-social-accounts-table into launchpad:db-devel

Proposed by Ines Almeida
Status: Merged
Approved by: Ines Almeida
Approved revision: 351add36a8142fed801e9294d1ab75c22d87f976
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~ines-almeida/launchpad:db-add-social-accounts-table
Merge into: launchpad:db-devel
Diff against target: 26 lines (+20/-0)
1 file modified
database/schema/patch-2211-25-0.sql (+20/-0)
Reviewer Review Type Date Requested Status
William Grant db Approve
Simone Pelosi Approve
Review via email: mp+457221@code.launchpad.net

Commit message

db: create new SocialAccounts table

Description of the change

This is the initial step for the Matrix integration with Launchpad

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) wrote :

Launchpad PostgreSQL table names are lowercase and singular: it should be "socialaccount".

Should we have an index on platform as well, to make debugging and maintenance operations easier?

Could this replace the existing ircid, jabberid, wikiname tables?

Revision history for this message
Ines Almeida (ines-almeida) wrote :

- Updated to the singular form, but we have a bunch of tables with PascalCase looking at recent patches?

- Added. Guruprasad had already suggested it. I didn't add it from the start because I doubt we will use it in the UI + API, but I agree it doesn't hurt to add and can be good for debugging.

- Yes, but we wont' do that right now. For now the focus is adding a new social platform in a way that is sustainable to add others later; later we might migrate those existing tables.

Revision history for this message
Simone Pelosi (pelpsi) wrote :

Looks good to me, just thinking if `identifier` is the correct attribute name here

review: Approve
Revision history for this message
William Grant (wgrant) :
review: Approve (db)
Revision history for this message
Ines Almeida (ines-almeida) wrote :

Renamed 'identifier' to 'identity' after a quick discussion with the team at standup

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/database/schema/patch-2211-25-0.sql b/database/schema/patch-2211-25-0.sql
2new file mode 100644
3index 0000000..ae06dd7
4--- /dev/null
5+++ b/database/schema/patch-2211-25-0.sql
6@@ -0,0 +1,20 @@
7+-- Copyright 2023 Canonical Ltd. This software is licensed under the
8+-- GNU Affero General Public License version 3 (see the file LICENSE).
9+
10+SET client_min_messages=ERROR;
11+
12+CREATE TABLE SocialAccount (
13+ id serial PRIMARY KEY,
14+ person integer REFERENCES Person NOT NULL,
15+ platform integer NOT NULL,
16+ identity jsonb NOT NULL
17+);
18+
19+COMMENT ON COLUMN SocialAccount.person IS 'Person the social media account belongs to.';
20+COMMENT ON COLUMN SocialAccount.platform IS 'Social media platform.';
21+COMMENT ON COLUMN SocialAccount.identity IS 'Data for identifying the social media account (JSON format specific per social media platform).';
22+
23+CREATE INDEX socialaccount__person__idx ON SocialAccount (person);
24+CREATE INDEX socialaccount__platform__idx ON SocialAccount (platform);
25+
26+INSERT INTO LaunchpadDatabaseRevision VALUES (2211, 25, 0);

Subscribers

People subscribed via source and target branches

to status/vote changes: