Skip to content

Commit 73c1f96

Browse files
committed
Revert "chore: Finalize Reviews DB schema."
This reverts commit 139490e.
1 parent 0fb01f9 commit 73c1f96

File tree

4 files changed

+49
-70
lines changed

4 files changed

+49
-70
lines changed

src/event-db/migrations/V11__reviews.sql

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55

66
CREATE TABLE subscription
77
(
8-
row_id SERIAL PRIMARY KEY,
9-
user_id INTEGER NOT NULL,
10-
event_id INTEGER NOT NULL,
11-
role INTEGER NOT NULL,
12-
status INTEGER NOT NULL,
13-
extra JSONB NULL,
8+
row_id SERIAL PRIMARY KEY,
9+
user_id INTEGER NOT NULL,
10+
event_id INTEGER NOT NULL,
11+
role INTEGER NOT NULL,
12+
status INTEGER NOT NULL,
13+
extra JSONB NULL,
1414

1515
FOREIGN KEY (user_id) REFERENCES catalyst_user(row_id) ON DELETE CASCADE,
1616
FOREIGN KEY (event_id) REFERENCES event(row_id) ON DELETE CASCADE
@@ -27,9 +27,6 @@ Some of these subscriptions will be automatically created by the system.
2727
The presence/status of subscriptions will determine user capabilities in the app.
2828
';
2929

30-
COMMENT ON COLUMN subscription.user_id IS 'The user ID this subscription belongs to.';
31-
COMMENT ON COLUMN subscription.event_id IS 'The event ID this subscription belongs to.';
32-
3330
COMMENT ON COLUMN subscription.role IS
3431
'This field describes the role of the user for this subscription.
3532
Possible values:
@@ -43,8 +40,7 @@ Specifically:
4340
4441
anonymous_id: str,
4542
subscription_date: datetime,
46-
preferred_categories: [int],
47-
reward_address: str
43+
preferred_categories: [int]
4844
';
4945

5046

@@ -55,11 +51,11 @@ reward_address: str
5551
-- - the allocation of moderations that needs to be done.
5652

5753
CREATE TABLE allocation (
58-
row_id SERIAL PRIMARY KEY,
54+
row_id SERIAL PRIMARY KEY,
5955
proposal_id INTEGER NULL,
60-
review_id INTEGER NULL,
61-
user_id INTEGER NOT NULL,
62-
type INTEGER NOT NULL,
56+
review_id INTEGER NULL,
57+
user_id INTEGER NOT NULL,
58+
type INTEGER NOT NULL,
6359

6460
FOREIGN KEY (proposal_id) REFERENCES proposal(row_id) ON DELETE CASCADE,
6561
FOREIGN KEY (review_id) REFERENCES proposal_review(row_id) ON DELETE CASCADE,
@@ -69,9 +65,9 @@ CREATE TABLE allocation (
6965

7066
COMMENT ON TABLE allocation IS 'The relationship between users and proposals or proposals_reviews.';
7167
COMMENT ON COLUMN allocation.row_id IS 'Synthetic ID of this relationship.';
72-
COMMENT ON COLUMN allocation.proposal_id IS 'The proposal ID the relationship belongs to.';
73-
COMMENT ON COLUMN allocation.review_id IS 'The review ID the relationship belongs to.';
74-
COMMENT ON COLUMN allocation.user_id IS 'The user ID the relationship belongs to.';
68+
COMMENT ON COLUMN allocation.proposal_id IS 'The proposal the relationship is related to.';
69+
COMMENT ON COLUMN allocation.review_id IS 'The review the relationship is related to.';
70+
COMMENT ON COLUMN allocation.user_id IS 'The user the relationship is related to.';
7571
COMMENT ON COLUMN allocation.type IS 'The type of relationship stored.
7672
Possible values:
7773
0: proposal ownership relation. proposal_id and user_id are required
@@ -86,11 +82,11 @@ CREATE INDEX idx_allocation_user_type ON allocation(user_id, type);
8682
-- Moderation - Defines the moderation submitted by users for each proposal_review.
8783

8884
CREATE TABLE moderation (
89-
row_id SERIAL PRIMARY KEY,
90-
review_id INTEGER NOT NULL,
91-
user_id INTEGER NOT NULL,
92-
classification INTEGER NOT NULL,
93-
rationale VARCHAR,
85+
row_id SERIAL PRIMARY KEY,
86+
review_id INTEGER NOT NULL,
87+
user_id INTEGER NOT NULL,
88+
classification INTEGER NOT NULL,
89+
rationale VARCHAR,
9490
UNIQUE (review_id, user_id),
9591

9692
FOREIGN KEY (review_id) REFERENCES proposal_review(row_id) ON DELETE CASCADE,
@@ -100,7 +96,7 @@ CREATE TABLE moderation (
10096

10197
COMMENT ON TABLE moderation IS 'An individual moderation for a proposal review.';
10298
COMMENT ON COLUMN moderation.row_id IS 'Synthetic ID of this moderation.';
103-
COMMENT ON COLUMN moderation.review_id IS 'The review ID the moderation belongs to.';
104-
COMMENT ON COLUMN moderation.user_id IS 'The user ID the moderation belongs to.';
99+
COMMENT ON COLUMN moderation.review_id IS 'The review the moderation is related to.';
100+
COMMENT ON COLUMN moderation.user_id IS 'The user the moderation is submitted from.';
105101
COMMENT ON COLUMN moderation.classification IS 'The value used to describe the moderation (e.g. 0: excluded, 1: included).';
106102
COMMENT ON COLUMN moderation.rationale IS 'The rationale for the given classification.';

src/event-db/migrations/V4__catalyst_id.sql

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,41 +5,21 @@
55

66
CREATE TABLE catalyst_id_map
77
(
8-
row_id SERIAL PRIMARY KEY,
9-
catalyst_id VARCHAR NOT NULL,
10-
email VARCHAR NOT NULL,
11-
username VARCHAR NOT NULL,
12-
signed_email VARCHAR NOT NULL,
13-
status INTEGER NOT NULL,
14-
confirmation_token VARCHAR,
15-
confirmation_requested_at TIMESTAMP,
16-
confirmed_at TIMESTAMP,
8+
row_id SERIAL PRIMARY KEY,
9+
catalyst_id VARCHAR NOT NULL,
10+
email VARCHAR NOT NULL,
11+
signed_email VARCHAR NOT NULL,
12+
status INTEGER NOT NULL,
13+
confirmation_token VARCHAR NOT NULL,
1714

1815
UNIQUE(catalyst_id)
1916
);
2017

2118
CREATE UNIQUE INDEX catalyst_id_idx ON catalyst_id_map(catalyst_id, email);
2219

23-
COMMENT ON TABLE catalyst_id_map IS '
24-
The `catalyst_id_map` table is used to store the map between the CatalystID and email/username for each user.
25-
Because the Catalyst RBAC registration are stored on-chain, and for this reason are publicly accessible,
26-
sensitive information like email address will be stored in a centralized DB, keeping a reference to the CatalystID.
27-
The email address is stored only when its signature corresponds to the CatalystID.
28-
';
29-
COMMENT ON COLUMN catalyst_id_map.catalyst_id IS '
30-
It contains the unique part of the CatalystID.
31-
Given a full CatalystID like `id.catalyst://[email protected]/FftxFnOrj2qmTuB2oZG2v0YEWJfKvQ9Gg8AgNAhDsKE`
32-
The scheme and the username are omitted and only the unique part `preprod.cardano/FftxFnOrj2qmTuB2oZG2v0YEWJfKvQ9Gg8AgNAhDsKE`
33-
is stored in this field.
34-
';
35-
COMMENT ON COLUMN catalyst_id_map.email IS 'The email address stored in plaintext.';
36-
COMMENT ON COLUMN catalyst_id_map.username IS 'The username extracted from the CatalystID stored in plaintext.';
37-
COMMENT ON COLUMN catalyst_id_map.signed_email IS 'The signed document that includes the email address.';
20+
COMMENT ON COLUMN catalyst_id_map.email IS 'The email is stored encrypted.';
3821
COMMENT ON COLUMN catalyst_id_map.status IS '
3922
Describes the status of an account:
4023
0: Inactive
4124
1: Active
42-
2: Banned.';
43-
COMMENT ON COLUMN catalyst_id_map.confirmation_token IS 'The token that is generated for the email confirmation.';
44-
COMMENT ON COLUMN catalyst_id_map.confirmation_requested_at IS 'The timestamp to validate confirmation token validity.';
45-
COMMENT ON COLUMN catalyst_id_map.confirmed_at IS 'The timestamp of the email confirmation.';
25+
2: Banned.';

src/event-db/migrations/V4__proposal_tables.sql

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,10 @@ CREATE TABLE proposal_review (
101101
proposal_id INTEGER NOT NULL,
102102
assessor VARCHAR NOT NULL,
103103
assessor_level INTEGER,
104+
reward_address TEXT,
104105

106+
-- These fields are deprecated and WILL BE removed in a future migration.
107+
-- They MUST only be used for Vit-SS compatibility.
105108
impact_alignment_rating_given INTEGER,
106109
impact_alignment_note VARCHAR,
107110
feasibility_rating_given INTEGER,
@@ -117,23 +120,31 @@ CREATE TABLE proposal_review (
117120

118121
COMMENT ON TABLE proposal_review IS 'All Reviews.';
119122
COMMENT ON COLUMN proposal_review.row_id IS 'Synthetic Unique Key.';
120-
COMMENT ON COLUMN proposal_review.proposal_id IS 'The Proposal id this review belongs to.';
121-
COMMENT ON COLUMN proposal_review.user_id IS 'The user id this review belongs to.';
122-
COMMENT ON COLUMN proposal_review.assessor IS 'Assessors Anonymized ID.';
123+
COMMENT ON COLUMN proposal_review.proposal_id IS 'The Proposal this review is for.';
124+
COMMENT ON COLUMN proposal_review.assessor IS 'Assessors Anonymized ID';
123125
COMMENT ON COLUMN proposal_review.assessor_level IS 'Assessors level ID';
126+
COMMENT ON COLUMN proposal_review.reward_address IS 'Assessors reward address';
124127

125128
COMMENT ON COLUMN proposal_review.impact_alignment_rating_given IS
126-
'The numeric rating assigned to the proposal by the assessor.';
129+
'The numeric rating assigned to the proposal by the assessor.
130+
DEPRECATED: Only used for Vit-SS compatibility.';
127131
COMMENT ON COLUMN proposal_review.impact_alignment_note IS
128-
'A note about why the impact rating was given.';
132+
'A note about why the impact rating was given.
133+
DEPRECATED: Only used for Vit-SS compatibility.';
134+
129135
COMMENT ON COLUMN proposal_review.feasibility_rating_given IS
130-
'The numeric feasibility rating given.';
136+
'The numeric feasibility rating given.
137+
DEPRECATED: Only used for Vit-SS compatibility.';
131138
COMMENT ON COLUMN proposal_review.feasibility_note IS
132-
'A note about why the feasibility rating was given.';
139+
'A note about why the feasibility rating was given.
140+
DEPRECATED: Only used for Vit-SS compatibility.';
141+
133142
COMMENT ON COLUMN proposal_review.auditability_rating_given IS
134-
'The numeric auditability rating given.';
143+
'The numeric auditability rating given.
144+
DEPRECATED: Only used for Vit-SS compatibility.';
135145
COMMENT ON COLUMN proposal_review.auditability_note IS
136-
'A note about the auditability rating given.';
146+
'A note about the auditability rating given.
147+
DEPRECATED: Only used for Vit-SS compatibility.';
137148

138149
COMMENT ON COLUMN proposal_review.ranking IS
139150
'Numeric Measure of quality of this review according to veteran community advisors.

src/event-db/migrations/V5__user.sql

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,6 @@ CREATE TABLE catalyst_user
1717
CREATE UNIQUE INDEX user_catalyst_id_idx ON catalyst_user(catalyst_id);
1818

1919

20-
COMMENT ON TABLE catalyst_user IS '
21-
This tables stores the user account for the Review Module.
22-
It contains a reference to the catalyst_id that is used as public and unique identifier.
23-
';
24-
25-
COMMENT ON COLUMN catalyst_user.catalyst_id IS 'The catalyst_id this account belongs to.';
26-
COMMENT ON COLUMN catalyst_user.enc_password IS 'The encrypted password.';
27-
COMMENT ON COLUMN catalyst_user.salt IS 'The salt for the password encryption.';
2820
COMMENT ON COLUMN catalyst_user.extra IS
2921
'This field is used to store all meta information about a user that
3022
are required by the application. Specifically:

0 commit comments

Comments
 (0)