Skip to content

Commit

Permalink
update tables
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-Leshiy committed May 23, 2023
1 parent eba0935 commit 75eea33
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 39 deletions.
11 changes: 5 additions & 6 deletions Makefiles/db.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,11 @@ psql -U catalyst-event-dev -d CatalystEventDev -f test_data/02_snapshot_table.sq
psql -U catalyst-event-dev -d CatalystEventDev -f test_data/03_voter_table.sql ${@}
psql -U catalyst-event-dev -d CatalystEventDev -f test_data/04_contribution_table.sql ${@}
psql -U catalyst-event-dev -d CatalystEventDev -f test_data/05_goal_table.sql ${@}
psql -U catalyst-event-dev -d CatalystEventDev -f test_data/06_voting_group_table.sql ${@}
psql -U catalyst-event-dev -d CatalystEventDev -f test_data/07_objective_table.sql ${@}
psql -U catalyst-event-dev -d CatalystEventDev -f test_data/08_proposal_table.sql ${@}
psql -U catalyst-event-dev -d CatalystEventDev -f test_data/09_proposal_review_table.sql ${@}
psql -U catalyst-event-dev -d CatalystEventDev -f test_data/10_review_rating_table.sql ${@}
psql -U catalyst-event-dev -d CatalystEventDev -f test_data/11_objective_review_metric_table.sql ${@}
psql -U catalyst-event-dev -d CatalystEventDev -f test_data/06_objective_table.sql ${@}
psql -U catalyst-event-dev -d CatalystEventDev -f test_data/07_proposal_table.sql ${@}
psql -U catalyst-event-dev -d CatalystEventDev -f test_data/08_proposal_review_table.sql ${@}
psql -U catalyst-event-dev -d CatalystEventDev -f test_data/09_review_rating_table.sql ${@}
psql -U catalyst-event-dev -d CatalystEventDev -f test_data/10_objective_review_metric_table.sql ${@}
'''

# Install historic data for past events
Expand Down
28 changes: 12 additions & 16 deletions src/event-db/migrations/V5__vote_plan.sql
Original file line number Diff line number Diff line change
Expand Up @@ -23,37 +23,33 @@ COMMENT ON COLUMN voteplan_category.public_key IS 'Does this vote plan category
-- groups

CREATE TABLE voting_group (
row_id SERIAL PRIMARY KEY,
group_id VARCHAR NOT NULL,
event_id INTEGER NOT NULL,
token_id VARCHAR,

FOREIGN KEY(event_id) REFERENCES event(row_id) ON DELETE CASCADE
name TEXT PRIMARY KEY,
);

CREATE UNIQUE INDEX token_event_id ON voting_group (token_id, event_id);
INSERT INTO voting_group (name)
VALUES
('direct'), -- Direct Voters
('drep'); -- Delegated Voter (Check what is the real name for this group we already use in snapshot)

COMMENT ON TABLE voting_group IS 'All Groups.';
COMMENT ON COLUMN voting_group.row_id IS 'Synthetic Unique Key.';
COMMENT ON COLUMN voting_group.group_id IS 'The ID of this voting group.';
COMMENT ON COLUMN voting_group.event_id IS 'The event this voting group belongs to.';
COMMENT ON COLUMN voting_group.token_id IS 'The ID of the voting token used by this group.';
COMMENT ON COLUMN voting_group.name IS 'The ID of this voting group.';

-- Vote Plans

CREATE TABLE voteplan
(
row_id SERIAL PRIMARY KEY,
event_id INTEGER NOT NULL,
objective_id INTEGER NOT NULL,

id VARCHAR NOT NULL UNIQUE,
id VARCHAR NOT NULL,
category TEXT NOT NULL,
encryption_key VARCHAR,
group_id INTEGER,
group_id TEXT,
token_id TEXT,

FOREIGN KEY(event_id) REFERENCES event(row_id) ON DELETE CASCADE,
FOREIGN KEY(objective_id) REFERENCES objective(row_id) ON DELETE CASCADE,
FOREIGN KEY(category) REFERENCES voteplan_category(name) ON DELETE CASCADE,
FOREIGN KEY(group_id) REFERENCES voting_group(row_id) ON DELETE CASCADE
FOREIGN KEY(group_id) REFERENCES voting_group(name) ON DELETE CASCADE
);

COMMENT ON TABLE voteplan IS 'All Vote plans.';
Expand Down
6 changes: 2 additions & 4 deletions src/event-db/migrations/V9__vitss_compatibility.sql
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ CREATE VIEW voteplans AS SELECT
voting_group.token_id AS token_identifier
FROM voteplan
INNER JOIN event ON voteplan.event_id = event.row_id
INNER JOIN voting_group ON voteplan.group_id = voting_group.row_id;
INNER JOIN voting_group ON voteplan.group_id = voting_group.name;

COMMENT ON VIEW voteplans IS
'@omit
Expand Down Expand Up @@ -214,9 +214,7 @@ Do not use this VIEW for new queries, its ONLY for backward compatibility.';
-- VIT-SS Compatibility View - groups.

CREATE VIEW groups AS SELECT
event_id AS fund_id,
token_id AS token_identifier,
group_id AS group_id
name AS group_id
FROM voting_group;

COMMENT ON VIEW groups IS
Expand Down
13 changes: 0 additions & 13 deletions src/event-db/test_data/06_voting_group_table.sql

This file was deleted.

0 comments on commit 75eea33

Please sign in to comment.