diff --git a/catalyst-gateway/event-db/Earthfile b/catalyst-gateway/event-db/Earthfile new file mode 100644 index 00000000000..2e5ee86fd06 --- /dev/null +++ b/catalyst-gateway/event-db/Earthfile @@ -0,0 +1,92 @@ +# This is a Dockerfile for building a container image for the Catalyst Event Database. +# The container image is built from scratch and includes the necessary files for running +# the database and its associated software. + +VERSION 0.7 + +# cspell: words + +# Event db builder target. Prepares all necessary artifacts. +# Arguments: +# * with_historic_data: add historic data from the `historic_data` dir (default `true`). +# * with_test_data: add test data from the `test_data` dir (default `true`). +builder: + FROM github.com/input-output-hk/catalyst-ci/earthly/postgresql:v2.0.7+postgres-base + + ARG with_historic_data=true + ARG with_test_data=true + + WORKDIR /build + + COPY refinery.toml . + COPY --dir migrations . + RUN mkdir data + + IF [ $with_historic_data = true ] + COPY --dir historic_data . + + RUN python3 historic_data/fund_2/mk_fund2_sql.py historic_data/fund_2/fund2_database_encrypted.sqlite3 >> historic_data/fund_2.sql + RUN python3 historic_data/fund_3/mk_fund3_sql.py historic_data/fund_3/fund3_database_encrypted.sqlite3 >> historic_data/fund_3.sql + RUN python3 historic_data/fund_4/mk_fund4_sql.py historic_data/fund_4/fund4_database_encrypted.sqlite3 >> historic_data/fund_4.sql + RUN python3 historic_data/fund_5/mk_fund5_sql.py historic_data/fund_5/fund5_database_encrypted.sqlite3 >> historic_data/fund_5.sql + RUN python3 historic_data/fund_6/mk_fund6_sql.py historic_data/fund_6/fund6_database_encrypted.sqlite3 >> historic_data/fund_6.sql + RUN python3 historic_data/fund_7/mk_fund7_sql.py historic_data/fund_7/fund7_database_encrypted.sqlite3 >> historic_data/fund_7.sql + RUN python3 historic_data/fund_8/mk_fund8_sql.py historic_data/fund_8/fund8_database_encrypted.sqlite3 >> historic_data/fund_8.sql + RUN python3 historic_data/fund_9/mk_fund9_sql.py historic_data/fund_9/fund9_database_encrypted.sqlite3 >> historic_data/fund_9.sql + RUN python3 historic_data/fund_9/mk_fund9_voteplan_sql.py historic_data/fund_9/fund9_database_encrypted.sqlite3 >> historic_data/fund_9.sql + + RUN mv ./historic_data/*.sql ./data + END + + IF [ $with_test_data = true ] + COPY --dir test_data . + + RUN mv ./test_data/*.sql ./data + END + + DO github.com/input-output-hk/catalyst-ci/earthly/postgresql:v2.0.7+BUILDER + +check: + FROM +builder + + DO github.com/input-output-hk/catalyst-ci/earthly/postgresql:v2.0.7+CHECK + +format: + LOCALLY + + DO github.com/input-output-hk/catalyst-ci/earthly/postgresql:v2.0.7+FORMAT --src=$(echo ${PWD}) + +# Build event db docker image. +# Arguments: +# * tag: docker image `tag`. +# * registry: docker image `registry`. +# * with_historic_data: add historic data from the `historic_data` dir (default `true`). +# * with_test_data: add test data from the `test_data` dir (default `true`). +build: + ARG with_historic_data=true + ARG with_test_data=true + ARG tag="latest" + ARG registry + + FROM +builder --with_historic_data=$with_historic_data --with_test_data=$with_test_data + + DO github.com/input-output-hk/catalyst-ci/earthly/postgresql:v2.0.7+BUILD --tag=$tag --registry=$registry --image_name=event-db + +test: + FROM github.com/input-output-hk/catalyst-ci/earthly/postgresql:v2.0.7+postgres-base + + COPY github.com/input-output-hk/catalyst-ci/earthly/utils:v2.0.7+shell-assert/assert.sh . + + COPY ./docker-compose.yml . + WITH DOCKER \ + --compose docker-compose.yml \ + --load event-db:latest=(+build --with_historic_data=false) \ + --service event-db \ + --allow-privileged + RUN sleep 5;\ + res=$(psql postgresql://catalyst-event-dev:CHANGE_ME@0.0.0.0:5432/CatalystEventDev -c "SELECT COUNT(*) FROM event");\ + + source assert.sh;\ + expected=$(printf " count \n-------\n 5\n(1 row)");\ + assert_eq "$expected" "$res" + END diff --git a/catalyst-gateway/event-db/Readme.md b/catalyst-gateway/event-db/Readme.md index f91d270db26..a8168c04b00 100644 --- a/catalyst-gateway/event-db/Readme.md +++ b/catalyst-gateway/event-db/Readme.md @@ -1,75 +1,27 @@ # Catalyst Event Database -This crate defines the structure and RUST access methods for the Catalyst Event Database. +This crate defines the necessary migrations, seed data and docker image builder for the Catalyst Event Database. ## Starting a Local Test DB with Docker and Earthly Firstly you will need to prepare a docker images with all migrations and data. -Prepare a event-db docker image with the historic data -(from the root directory) +Prepare a event-db docker image with the historic and test data ```sh -earthly ./containers/event-db-migrations+docker -``` - -Prepare a event-db docker image with the test data -(from the root directory) - -```sh -earthly ./containers/event-db-migrations+docker --data=test +earthly ./catalyst-gateway/event-db+build --tag "latest" --registry "" --with_historic_data true --with_test_data true ``` Run a event db docker container -(from the root directory) ```sh -docker-compose -f src/event-db/docker-compose.yml up migrations +docker-compose -f catalyst-gateway/event-db/docker-compose.yml up event-db ``` -This will run postgres on port `5432` - -## GraphQL +This will run postgres on port `5432`. -GraphQL is ONLY used for the admin interface. -It is configured with the `setup/graphql-setup.sql`. - -For local testing, make sure the local `event-db` is setup and running, as described above. -Then: +To test that docker image builds fine and migrations correctly applies run ```sh -setup/start-graphql.sh +earthly -P ./catalyst-gateway/event-db+test ``` - -See for documentation on the GraphQL server. - -### GraphQL Users - -There are two GraphQL Users: - -* `cat_admin`: Full admin access to the database. -* `cat_anon`: Unauthenticated read-only access to the database. - -To authenticate, as the `cat_admin` user, execute the `authenticate` mutation. -This will return a Signed JWT Token for the user. -The JWT Token needs to be included as a `bearer` token `Authorization` header in subsequent requests. -Authentication only last 1 Hour, after which a new token must be requested. - -When authenticated as the `cat_admin` user, new `cat_admin` users can be registered with the `registerAdmin` mutation. - -Further Security Roles or Admin management functions can be added as required. - -#### Authentication API - -The GraphQL server exposes 2 **Mutations** that are used for security. - -If the user is NOT authenticated, they can not update any data in the database, only read data. - -To authenticate run the `authenticate` mutation with the email address and password of the user to be authenticated. -If successful, this mutation will return a JWT which will have 1 hr of Life. -Place the returned JWT in an `Authorization: Bearer ` header for all subsequent calls. - -`currentAcct` query will return the authenticated user's current account details and role. - -To register a new user, the `registerAdmin` mutation can be used. -It will only work if the user is properly authenticated with a `cat_admin` role. diff --git a/catalyst-gateway/event-db/docker-compose.yml b/catalyst-gateway/event-db/docker-compose.yml index f4127203800..b8d1de641f3 100644 --- a/catalyst-gateway/event-db/docker-compose.yml +++ b/catalyst-gateway/event-db/docker-compose.yml @@ -1,36 +1,23 @@ version: "3" -services: - postgres: - image: postgres:14 - restart: unless-stopped - environment: - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - POSTGRES_DB: CatalystEventDev - healthcheck: - test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"] - interval: 2s - timeout: 5s - retries: 10 - ports: - - 5432:5432 +# cspell: words - migrations: - image: migrations:latest +services: + event-db: + image: event-db:latest environment: # Required environment variables for migrations - - DB_HOST=postgres + - DB_HOST=localhost - DB_PORT=5432 - DB_NAME=CatalystEventDev + - DB_DESCRIPTION="Catalyst Event DB" - DB_SUPERUSER=postgres - DB_SUPERUSER_PASSWORD=postgres - DB_USER=catalyst-event-dev - DB_USER_PASSWORD=CHANGE_ME - - ADMIN_ROLE_PASSWORD=CHANGE_ME - - ADMIN_USER_PASSWORD=CHANGE_ME - - ANON_ROLE_PASSWORD=CHANGE_ME - - STAGE=dev - depends_on: - postgres: - condition: service_healthy + + - INIT_AND_DROP_DB=true + - WITH_MIGRATIONS=true + - WITH_SEED_DATA=true + ports: + - 5432:5432 diff --git a/catalyst-gateway/event-db/historic_data/fund_0.sql b/catalyst-gateway/event-db/historic_data/fund_0.sql index 88e39ebaf21..c5c85bfbdc0 100644 --- a/catalyst-gateway/event-db/historic_data/fund_0.sql +++ b/catalyst-gateway/event-db/historic_data/fund_0.sql @@ -13,47 +13,54 @@ DELETE FROM event WHERE row_id = 0; -- Create the Event record for Fund 0 INSERT INTO event -(row_id, name, description, - start_time, - end_time, - registration_snapshot_time, - snapshot_start, - voting_power_threshold, - max_voting_power_pct, - insight_sharing_start, - proposal_submission_start, - refine_proposals_start, - finalize_proposals_start, - proposal_assessment_start, - assessment_qa_start, - voting_start, - voting_end, - tallying_end, - block0, - block0_hash, - committee_size, - committee_threshold) +( + row_id, name, description, + start_time, + end_time, + registration_snapshot_time, + snapshot_start, + voting_power_threshold, + max_voting_power_pct, + insight_sharing_start, + proposal_submission_start, + refine_proposals_start, + finalize_proposals_start, + proposal_assessment_start, + assessment_qa_start, + voting_start, + voting_end, + tallying_end, + block0, + block0_hash, + committee_size, + committee_threshold +) VALUES -(0, 'Catalyst Fund 0', 'Catalyst Internal Test Fund - Voting by Focus Group', - '2020-05-22 00:00:00', -- Start Time - Date accurate, time not known. - '2020-06-24 00:00:00', -- End Time - Date accurate, time not known. - '2020-06-08 00:00:00', -- Registration Snapshot Time - Date accurate, time not known. - '2020-06-08 00:00:00', -- Snapshot Start - Date Assumed, time not known. - 1, -- Voting Power Threshold - Unknown, assume 1 - 100, -- Max Voting Power PCT - No max% threshold used in this fund. - NULL, -- Insight Sharing Start - None - '2020-05-22 00:00:00', -- Proposal Submission Start - Date accurate, time not known. - NULL, -- Refine Proposals Start - Date accurate, time not known. - '2020-05-29 00:00:00', -- Finalize Proposals Start - Date accurate, time not known. - NULL, -- Proposal Assessment Start - None - NULL, -- Assessment QA Start - None - '2020-06-15 00:00:00', -- Voting Starts - Date Accurate, time not known. - '2020-06-19 00:00:00', -- Voting Ends - Date Accurate, time not known. - '2020-06-19 12:00:00', -- Tallying Ends - Date Accurate, time not known. - NULL, -- Block 0 Data - Not Known - NULL, -- Block 0 Hash - Not Known - 0, -- Committee Size - Not Known - 0 -- Committee Threshold - Not Known - ); - +( + 0, 'Catalyst Fund 0', 'Catalyst Internal Test Fund - Voting by Focus Group', + '2020-05-22 00:00:00', -- Start Time - Date accurate, time not known. + '2020-06-24 00:00:00', -- End Time - Date accurate, time not known. + -- Registration Snapshot Time - Date accurate, time not known. + '2020-06-08 00:00:00', + '2020-06-08 00:00:00', -- Snapshot Start - Date Assumed, time not known. + 1, -- Voting Power Threshold - Unknown, assume 1 + -- Max Voting Power PCT - No max% threshold used in this fund. + 100, + NULL, -- Insight Sharing Start - None + -- Proposal Submission Start - Date accurate, time not known. + '2020-05-22 00:00:00', + -- Refine Proposals Start - Date accurate, time not known. + NULL, + -- Finalize Proposals Start - Date accurate, time not known. + '2020-05-29 00:00:00', + NULL, -- Proposal Assessment Start - None + NULL, -- Assessment QA Start - None + '2020-06-15 00:00:00', -- Voting Starts - Date Accurate, time not known. + '2020-06-19 00:00:00', -- Voting Ends - Date Accurate, time not known. + '2020-06-19 12:00:00', -- Tallying Ends - Date Accurate, time not known. + NULL, -- Block 0 Data - Not Known + NULL, -- Block 0 Hash - Not Known + 0, -- Committee Size - Not Known + 0 -- Committee Threshold - Not Known +); diff --git a/catalyst-gateway/event-db/historic_data/fund_1.sql b/catalyst-gateway/event-db/historic_data/fund_1.sql index a88ecb20c59..5c277a080d0 100644 --- a/catalyst-gateway/event-db/historic_data/fund_1.sql +++ b/catalyst-gateway/event-db/historic_data/fund_1.sql @@ -13,47 +13,53 @@ DELETE FROM event WHERE row_id = 1; -- Create the Event record for Fund 0 INSERT INTO event -(row_id, name, description, - start_time, - end_time, - registration_snapshot_time, - snapshot_start, - voting_power_threshold, - max_voting_power_pct, - insight_sharing_start, - proposal_submission_start, - refine_proposals_start, - finalize_proposals_start, - proposal_assessment_start, - assessment_qa_start, - voting_start, - voting_end, - tallying_end, - block0, - block0_hash, - committee_size, - committee_threshold) +( + row_id, name, description, + start_time, + end_time, + registration_snapshot_time, + snapshot_start, + voting_power_threshold, + max_voting_power_pct, + insight_sharing_start, + proposal_submission_start, + refine_proposals_start, + finalize_proposals_start, + proposal_assessment_start, + assessment_qa_start, + voting_start, + voting_end, + tallying_end, + block0, + block0_hash, + committee_size, + committee_threshold +) VALUES -(1, 'Catalyst Fund 1', 'Public Pilot Run', - '2020-08-08 00:00:00', -- Start Time - Date accurate, time not known. - '2020-09-22 00:00:00', -- End Time - Date accurate, time not known. - '2020-09-14 12:00:05', -- Registration Snapshot Time - Slot 8518514 - '2020-09-15 00:00:00', -- Snapshot Start - Date/time not known. - 1, -- Voting Power Threshold - Unknown, assume 1 - 100, -- Max Voting Power PCT - No max% threshold used in this fund. - NULL, -- Insight Sharing Start - None - '2020-08-08 00:00:00', -- Proposal Submission Start - Date accurate, time not known. - NULL, -- Refine Proposals Start - Date accurate, time not known. - '2020-09-11 00:00:00', -- Finalize Proposals Start - Date accurate, time not known. - NULL, -- Proposal Assessment Start - None - NULL, -- Assessment QA Start - None - '2020-09-17 00:00:00', -- Voting Starts - Date Accurate, time not known. - '2020-09-21 00:00:00', -- Voting Ends - Date Accurate, time not known. - '2020-09-22 23:59:00', -- Tallying Ends - Date Accurate, time not known. - NULL, -- Block 0 Data - Not Known - NULL, -- Block 0 Hash - Not Known - 0, -- Committee Size - Not Known - 0 -- Committee Threshold - Not Known - ); - +( + 1, 'Catalyst Fund 1', 'Public Pilot Run', + '2020-08-08 00:00:00', -- Start Time - Date accurate, time not known. + '2020-09-22 00:00:00', -- End Time - Date accurate, time not known. + '2020-09-14 12:00:05', -- Registration Snapshot Time - Slot 8518514 + '2020-09-15 00:00:00', -- Snapshot Start - Date/time not known. + 1, -- Voting Power Threshold - Unknown, assume 1 + -- Max Voting Power PCT - No max% threshold used in this fund. + 100, + NULL, -- Insight Sharing Start - None + -- Proposal Submission Start - Date accurate, time not known. + '2020-08-08 00:00:00', + -- Refine Proposals Start - Date accurate, time not known. + NULL, + -- Finalize Proposals Start - Date accurate, time not known. + '2020-09-11 00:00:00', + NULL, -- Proposal Assessment Start - None + NULL, -- Assessment QA Start - None + '2020-09-17 00:00:00', -- Voting Starts - Date Accurate, time not known. + '2020-09-21 00:00:00', -- Voting Ends - Date Accurate, time not known. + '2020-09-22 23:59:00', -- Tallying Ends - Date Accurate, time not known. + NULL, -- Block 0 Data - Not Known + NULL, -- Block 0 Hash - Not Known + 0, -- Committee Size - Not Known + 0 -- Committee Threshold - Not Known +); diff --git a/catalyst-gateway/event-db/migrations/V1__config_tables.sql b/catalyst-gateway/event-db/migrations/V1__config_tables.sql index 39d86ecec8e..d9e4a014047 100644 --- a/catalyst-gateway/event-db/migrations/V1__config_tables.sql +++ b/catalyst-gateway/event-db/migrations/V1__config_tables.sql @@ -4,10 +4,10 @@ CREATE TABLE IF NOT EXISTS refinery_schema_history ( - version INTEGER NOT NULL PRIMARY KEY, - name VARCHAR(255), - applied_on VARCHAR(255), - checksum VARCHAR(255) + version INTEGER NOT NULL PRIMARY KEY, + name VARCHAR(255), + applied_on VARCHAR(255), + checksum VARCHAR(255) ); COMMENT ON TABLE refinery_schema_history IS @@ -21,14 +21,14 @@ Managed by the `refinery` cli tool. CREATE TABLE config ( row_id SERIAL PRIMARY KEY, - id VARCHAR NOT NULL, - id2 VARCHAR NOT NULL, - id3 VARCHAR NOT NULL, - value JSONB NULL + id VARCHAR NOT NULL, + id2 VARCHAR NOT NULL, + id3 VARCHAR NOT NULL, + value JSONB NULL ); -- id+id2+id3 must be unique, they are a combined key. -CREATE UNIQUE INDEX config_idx ON config(id,id2,id3); +CREATE UNIQUE INDEX config_idx ON config (id, id2, id3); COMMENT ON TABLE config IS 'General JSON Configuration and Data Values. @@ -69,7 +69,7 @@ Defined Data Formats: COMMENT ON COLUMN config.row_id IS 'Synthetic unique key. Always lookup using id.'; -COMMENT ON COLUMN config.id IS 'The name/id of the general config value/variable'; +COMMENT ON COLUMN config.id IS 'The name/id of the general config value/variable'; COMMENT ON COLUMN config.id2 IS '2nd ID of the general config value. Must be defined, use "" if not required.'; diff --git a/catalyst-gateway/event-db/migrations/V2__event_tables.sql b/catalyst-gateway/event-db/migrations/V2__event_tables.sql index d3c49347564..76f5ab17017 100644 --- a/catalyst-gateway/event-db/migrations/V2__event_tables.sql +++ b/catalyst-gateway/event-db/migrations/V2__event_tables.sql @@ -5,42 +5,44 @@ CREATE TABLE event ( - row_id SERIAL PRIMARY KEY, + row_id SERIAL PRIMARY KEY, - name TEXT NOT NULL, - description TEXT NOT NULL, + name TEXT NOT NULL, + description TEXT NOT NULL, - registration_snapshot_time TIMESTAMP, - snapshot_start TIMESTAMP, - voting_power_threshold BIGINT, - max_voting_power_pct NUMERIC(6,3) CONSTRAINT percentage CHECK (max_voting_power_pct <= 100 AND max_voting_power_pct >= 0), + registration_snapshot_time TIMESTAMP, + snapshot_start TIMESTAMP, + voting_power_threshold BIGINT, + max_voting_power_pct NUMERIC(6, 3) CONSTRAINT percentage CHECK ( + max_voting_power_pct <= 100 AND max_voting_power_pct >= 0 + ), - review_rewards BIGINT, + review_rewards BIGINT, - start_time TIMESTAMP, - end_time TIMESTAMP, + start_time TIMESTAMP, + end_time TIMESTAMP, - insight_sharing_start TIMESTAMP, - proposal_submission_start TIMESTAMP, - refine_proposals_start TIMESTAMP, - finalize_proposals_start TIMESTAMP, - proposal_assessment_start TIMESTAMP, - assessment_qa_start TIMESTAMP, - voting_start TIMESTAMP, - voting_end TIMESTAMP, - tallying_end TIMESTAMP, + insight_sharing_start TIMESTAMP, + proposal_submission_start TIMESTAMP, + refine_proposals_start TIMESTAMP, + finalize_proposals_start TIMESTAMP, + proposal_assessment_start TIMESTAMP, + assessment_qa_start TIMESTAMP, + voting_start TIMESTAMP, + voting_end TIMESTAMP, + tallying_end TIMESTAMP, - block0 BYTEA NULL, - block0_hash TEXT NULL, + block0 BYTEA NULL, + block0_hash TEXT NULL, - committee_size INTEGER NOT NULL, - committee_threshold INTEGER NOT NULL, + committee_size INTEGER NOT NULL, + committee_threshold INTEGER NOT NULL, - extra JSONB, - cast_to JSONB + extra JSONB, + cast_to JSONB ); -CREATE UNIQUE INDEX event_name_idx ON event(name); +CREATE UNIQUE INDEX event_name_idx ON event (name); COMMENT ON TABLE event IS 'The basic parameters of each voting/decision event.'; COMMENT ON COLUMN event.row_id IS 'Synthetic Unique ID for each event.'; @@ -97,7 +99,7 @@ COMMENT ON COLUMN event.tallying_end IS 'The latest time that tallying the event can complete by. NULL = Not yet defined.'; -COMMENT ON COLUMN event.block0 IS +COMMENT ON COLUMN event.block0 IS 'The copy of Block 0 used to start the Blockchain. NULL = Blockchain not started yet.'; @@ -105,11 +107,11 @@ COMMENT ON COLUMN event.block0_hash IS 'The hash of block 0. NULL = Blockchain not started yet.'; -COMMENT ON COLUMN event.committee_size IS +COMMENT ON COLUMN event.committee_size IS 'The size of the tally committee. 0 = No Committee, and all votes are therefore public.'; -COMMENT ON COLUMN event.committee_threshold IS +COMMENT ON COLUMN event.committee_threshold IS 'The minimum size of the tally committee to perform the tally. Must be <= `committee_size`'; diff --git a/catalyst-gateway/event-db/migrations/V3__objective_tables.sql b/catalyst-gateway/event-db/migrations/V3__objective_tables.sql index d7f5f6dd6ae..27da6c8c92c 100644 --- a/catalyst-gateway/event-db/migrations/V3__objective_tables.sql +++ b/catalyst-gateway/event-db/migrations/V3__objective_tables.sql @@ -3,8 +3,8 @@ -- objective types table - Defines all currently known objectives types. CREATE TABLE objective_category ( - name TEXT PRIMARY KEY, - description TEXT + name TEXT PRIMARY KEY, + description TEXT ); COMMENT ON TABLE objective_category IS 'Defines all known and valid objective categories.'; @@ -12,18 +12,18 @@ COMMENT ON COLUMN objective_category.name IS 'The name of this objective categor COMMENT ON COLUMN objective_category.description IS 'A Description of this kind of objective category.'; -- Define known objective categories -INSERT INTO objective_category (name, description) +INSERT INTO objective_category (name, description) VALUES - ('catalyst-simple','A Simple choice'), - ('catalyst-native','??'), - ('catalyst-community-choice','Community collective decision'), - ('sve-decision','Special voting event decision'); +('catalyst-simple', 'A Simple choice'), +('catalyst-native', '??'), +('catalyst-community-choice', 'Community collective decision'), +('sve-decision', 'Special voting event decision'); -- known currencies - Defines all currently known currencies. CREATE TABLE currency ( - name TEXT PRIMARY KEY, - description TEXT + name TEXT PRIMARY KEY, + description TEXT ); COMMENT ON TABLE currency IS 'Defines all known and valid currencies.'; @@ -32,20 +32,23 @@ COMMENT ON COLUMN currency.description IS 'A Description of this kind of currenc -- Define known currencies -INSERT INTO currency (name, description) +INSERT INTO currency (name, description) VALUES - ('USD_ADA','US Dollars, converted to Cardano ADA at time of reward calculation.'), - ('ADA','Cardano ADA.'), - ('CLAP', 'CLAP tokens.'), - ('COTI', 'COTI tokens.'); +( + 'USD_ADA', + 'US Dollars, converted to Cardano ADA at time of reward calculation.' +), +('ADA', 'Cardano ADA.'), +('CLAP', 'CLAP tokens.'), +('COTI', 'COTI tokens.'); -- known vote options - Defines all currently known vote options. CREATE TABLE vote_options ( - id SERIAL PRIMARY KEY, + id SERIAL PRIMARY KEY, - idea_scale TEXT ARRAY UNIQUE, - objective TEXT ARRAY UNIQUE + idea_scale TEXT ARRAY UNIQUE, + objective TEXT ARRAY UNIQUE ); COMMENT ON TABLE vote_options IS 'Defines all known vote plan option types.'; @@ -54,9 +57,9 @@ COMMENT ON COLUMN vote_options.idea_scale IS 'How this vote option is represente COMMENT ON COLUMN vote_options.objective IS 'How the vote options is represented in the objective.'; -- Define known vote_options -INSERT INTO vote_options (idea_scale, objective) +INSERT INTO vote_options (idea_scale, objective) VALUES - ('{"blank", "yes", "no"}','{"yes", "no"}'); +('{"blank", "yes", "no"}', '{"yes", "no"}'); @@ -64,16 +67,16 @@ VALUES CREATE TABLE goal ( - id SERIAL PRIMARY KEY, - event_id INTEGER NOT NULL, + id SERIAL PRIMARY KEY, + event_id INTEGER NOT NULL, - idx INTEGER NOT NULL, - name VARCHAR NOT NULL, + idx INTEGER NOT NULL, + name VARCHAR NOT NULL, - FOREIGN KEY(event_id) REFERENCES event(row_id) ON DELETE CASCADE + FOREIGN KEY (event_id) REFERENCES event (row_id) ON DELETE CASCADE ); -CREATE UNIQUE INDEX goal_index ON goal(event_id, idx); +CREATE UNIQUE INDEX goal_index ON goal (event_id, idx); COMMENT ON TABLE goal IS 'The list of campaign goals for this event.'; COMMENT ON COLUMN goal.id IS 'Synthetic Unique Key.'; @@ -88,29 +91,29 @@ COMMENT ON INDEX goal_index IS 'An index to enforce uniqueness of the relative ` CREATE TABLE objective ( - row_id SERIAL PRIMARY KEY, + row_id SERIAL PRIMARY KEY, - id INTEGER NOT NULL, - event INTEGER NOT NULL, + id INTEGER NOT NULL, + event INTEGER NOT NULL, - category TEXT NOT NULL, - title TEXT NOT NULL, - description TEXT NOT NULL, + category TEXT NOT NULL, + title TEXT NOT NULL, + description TEXT NOT NULL, - deleted BOOLEAN NOT NULL DEFAULT FALSE, + deleted BOOLEAN NOT NULL DEFAULT FALSE, - rewards_currency TEXT, - rewards_total BIGINT, - rewards_total_lovelace BIGINT, - proposers_rewards BIGINT, - vote_options INTEGER, + rewards_currency TEXT, + rewards_total BIGINT, + rewards_total_lovelace BIGINT, + proposers_rewards BIGINT, + vote_options INTEGER, - extra JSONB, + extra JSONB, - FOREIGN KEY(event) REFERENCES event(row_id) ON DELETE CASCADE, - FOREIGN KEY(category) REFERENCES objective_category(name) ON DELETE CASCADE, - FOREIGN KEY(rewards_currency) REFERENCES currency(name) ON DELETE CASCADE, - FOREIGN KEY(vote_options) REFERENCES vote_options(id) ON DELETE CASCADE + FOREIGN KEY (event) REFERENCES event (row_id) ON DELETE CASCADE, + FOREIGN KEY (category) REFERENCES objective_category (name) ON DELETE CASCADE, + FOREIGN KEY (rewards_currency) REFERENCES currency (name) ON DELETE CASCADE, + FOREIGN KEY (vote_options) REFERENCES vote_options (id) ON DELETE CASCADE ); CREATE UNIQUE INDEX objective_idx ON objective (id, event); diff --git a/catalyst-gateway/event-db/migrations/V4__proposal_tables.sql b/catalyst-gateway/event-db/migrations/V4__proposal_tables.sql index 158adb8f805..283b3316577 100644 --- a/catalyst-gateway/event-db/migrations/V4__proposal_tables.sql +++ b/catalyst-gateway/event-db/migrations/V4__proposal_tables.sql @@ -4,35 +4,37 @@ CREATE TABLE proposal ( - row_id SERIAL PRIMARY KEY, - id INTEGER NOT NULL, - objective INTEGER NOT NULL, - title TEXT NOT NULL, - summary TEXT NOT NULL, - category TEXT NOT NULL, - public_key TEXT NOT NULL, - funds BIGINT NOT NULL, - url TEXT NOT NULL, - files_url TEXT NOT NULL, - impact_score BIGINT NOT NULL, - - deleted BOOLEAN NOT NULL DEFAULT FALSE, - - extra JSONB, - - proposer_name TEXT NOT NULL, - proposer_contact TEXT NOT NULL, - proposer_url TEXT NOT NULL, - proposer_relevant_experience TEXT NOT NULL, - bb_proposal_id BYTEA, - - bb_vote_options TEXT[], - - FOREIGN KEY(objective) REFERENCES objective(row_id) ON DELETE CASCADE, - FOREIGN KEY(bb_vote_options) REFERENCES vote_options(objective) ON DELETE CASCADE + row_id SERIAL PRIMARY KEY, + id INTEGER NOT NULL, + objective INTEGER NOT NULL, + title TEXT NOT NULL, + summary TEXT NOT NULL, + category TEXT NOT NULL, + public_key TEXT NOT NULL, + funds BIGINT NOT NULL, + url TEXT NOT NULL, + files_url TEXT NOT NULL, + impact_score BIGINT NOT NULL, + + deleted BOOLEAN NOT NULL DEFAULT FALSE, + + extra JSONB, + + proposer_name TEXT NOT NULL, + proposer_contact TEXT NOT NULL, + proposer_url TEXT NOT NULL, + proposer_relevant_experience TEXT NOT NULL, + bb_proposal_id BYTEA, + + bb_vote_options TEXT [], + + FOREIGN KEY (objective) REFERENCES objective (row_id) ON DELETE CASCADE, + FOREIGN KEY (bb_vote_options) REFERENCES vote_options ( + objective + ) ON DELETE CASCADE ); -CREATE UNIQUE INDEX proposal_index ON proposal(id, objective); +CREATE UNIQUE INDEX proposal_index ON proposal (id, objective); COMMENT ON TABLE proposal IS 'All Proposals for the current fund.'; @@ -73,21 +75,23 @@ COMMENT ON COLUMN proposal.extra IS -- Reviewer's levels table CREATE TABLE reviewer_level ( - row_id SERIAL PRIMARY KEY, - name TEXT NOT NULL, - total_reward_pct NUMERIC(6,3) CONSTRAINT percentage CHECK (total_reward_pct <= 100 AND total_reward_pct >= 0), + row_id SERIAL PRIMARY KEY, + name TEXT NOT NULL, + total_reward_pct NUMERIC(6, 3) CONSTRAINT percentage CHECK ( + total_reward_pct <= 100 AND total_reward_pct >= 0 + ), - event_id INTEGER NOT NULL, + event_id INTEGER NOT NULL, - FOREIGN KEY (event_id) REFERENCES event(row_id) ON DELETE CASCADE + FOREIGN KEY (event_id) REFERENCES event (row_id) ON DELETE CASCADE ); -COMMENT ON TABLE reviewer_level IS +COMMENT ON TABLE reviewer_level IS 'All levels of reviewers. This table represents all different types of reviewer`s levels, which is taken into account during rewarding process.'; COMMENT ON COLUMN reviewer_level.row_id IS 'Synthetic Unique Key'; COMMENT ON COLUMN reviewer_level.name IS 'Name of the reviewer level'; -COMMENT ON COLUMN reviewer_level.total_reward_pct IS +COMMENT ON COLUMN reviewer_level.total_reward_pct IS 'Total reviewer`s reward assigned to the specific level, which is defined as a percentage from the total pot of Community Review rewards (See `event.review_rewards` column).'; COMMENT ON COLUMN reviewer_level.event_id IS 'The specific Event ID this review level is part of.'; @@ -114,8 +118,10 @@ CREATE TABLE proposal_review ( ranking INTEGER, flags JSONB NULL, - FOREIGN KEY (proposal_id) REFERENCES proposal(row_id) ON DELETE CASCADE, - FOREIGN KEY (assessor_level) REFERENCES reviewer_level(row_id) ON DELETE CASCADE + FOREIGN KEY (proposal_id) REFERENCES proposal (row_id) ON DELETE CASCADE, + FOREIGN KEY (assessor_level) REFERENCES reviewer_level ( + row_id + ) ON DELETE CASCADE ); COMMENT ON TABLE proposal_review IS 'All Reviews.'; @@ -194,15 +200,16 @@ Each entry = -- Define known review metrics INSERT INTO review_metric (name, description, min, max, map) VALUES - ('impact', 'Impact Rating', 0, 5, NULL), - ('feasibility','Feasibility Rating', 0, 5, NULL), - ('auditability','Auditability Rating', 0, 5, NULL), - ('value','Value Proposition Rating', 0, 5, NULL), - ('vpa_ranking','VPA Ranking of the review',0,3, ARRAY [ - '{"name":"Excellent","desc":"Excellent Review"}', - '{"name":"Good","desc":"Could be improved."}', - '{"name":"FilteredOut","desc":"Exclude this review"}', - '{"name":"NA", "desc":"Not Applicable"}']::JSON[]); +('impact', 'Impact Rating', 0, 5, NULL), +('feasibility', 'Feasibility Rating', 0, 5, NULL), +('auditability', 'Auditability Rating', 0, 5, NULL), +('value', 'Value Proposition Rating', 0, 5, NULL), +('vpa_ranking', 'VPA Ranking of the review', 0, 3, ARRAY[ + '{"name":"Excellent","desc":"Excellent Review"}', + '{"name":"Good","desc":"Could be improved."}', + '{"name":"FilteredOut","desc":"Exclude this review"}', + '{"name":"NA", "desc":"Not Applicable"}' +]::JSON []); CREATE TABLE objective_review_metric ( row_id SERIAL PRIMARY KEY, @@ -211,10 +218,10 @@ CREATE TABLE objective_review_metric ( note BOOLEAN, review_group VARCHAR, - UNIQUE(objective, metric, review_group), + UNIQUE (objective, metric, review_group), - FOREIGN KEY (objective) REFERENCES objective(row_id) ON DELETE CASCADE, - FOREIGN KEY (metric) REFERENCES review_metric(row_id) ON DELETE CASCADE + FOREIGN KEY (objective) REFERENCES objective (row_id) ON DELETE CASCADE, + FOREIGN KEY (metric) REFERENCES review_metric (row_id) ON DELETE CASCADE ); @@ -235,18 +242,18 @@ CREATE TABLE review_rating ( review_id INTEGER NOT NULL, metric INTEGER NOT NULL, rating INTEGER NOT NULL, - note VARCHAR, + note VARCHAR, - UNIQUE ( review_id, metric ), + UNIQUE (review_id, metric), - FOREIGN KEY (review_id) REFERENCES proposal_review(row_id) ON DELETE CASCADE, - FOREIGN KEY (metric) REFERENCES review_metric(row_id) ON DELETE CASCADE + FOREIGN KEY (review_id) REFERENCES proposal_review (row_id) ON DELETE CASCADE, + FOREIGN KEY (metric) REFERENCES review_metric (row_id) ON DELETE CASCADE ); COMMENT ON TABLE review_rating IS 'An Individual rating for a metric given on a review.'; COMMENT ON COLUMN review_rating.row_id IS 'Synthetic ID of this individual rating.'; COMMENT ON COLUMN review_rating.review_id IS 'The review the metric is being given for.'; -COMMENT ON COLUMN review_rating.metric IS 'Metric the rating is being given for.'; -COMMENT ON COLUMN review_rating.rating IS 'The rating being given to the metric.'; -COMMENT ON COLUMN review_rating.note IS 'OPTIONAL: Note about the rating given.'; +COMMENT ON COLUMN review_rating.metric IS 'Metric the rating is being given for.'; +COMMENT ON COLUMN review_rating.rating IS 'The rating being given to the metric.'; +COMMENT ON COLUMN review_rating.note IS 'OPTIONAL: Note about the rating given.'; diff --git a/catalyst-gateway/event-db/migrations/V5__vote_plan.sql b/catalyst-gateway/event-db/migrations/V5__vote_plan.sql index 52c986b2069..48178183ed6 100644 --- a/catalyst-gateway/event-db/migrations/V5__vote_plan.sql +++ b/catalyst-gateway/event-db/migrations/V5__vote_plan.sql @@ -4,16 +4,16 @@ CREATE TABLE voteplan_category ( - name TEXT PRIMARY KEY, - public_key BOOL + name TEXT PRIMARY KEY, + public_key BOOL ); INSERT INTO voteplan_category (name, public_key) VALUES - ('public', false), -- Fully public votes only - ('private', true), -- Fully private votes only. - ('cast-private', true); -- Private until tally, then decrypted. +('public', false), -- Fully public votes only +('private', true), -- Fully private votes only. +('cast-private', true); -- Private until tally, then decrypted. COMMENT ON TABLE voteplan_category IS 'The category of vote plan currently supported.'; COMMENT ON COLUMN voteplan_category.name IS 'The UNIQUE name of this voteplan category.'; @@ -23,13 +23,13 @@ COMMENT ON COLUMN voteplan_category.public_key IS 'Does this vote plan category -- groups CREATE TABLE voting_group ( - name TEXT PRIMARY KEY + name TEXT PRIMARY KEY ); INSERT INTO voting_group (name) VALUES - ('direct'), -- Direct Voters - ('rep'); -- Delegated Voter (Check what is the real name for this group we already use in snapshot) +('direct'), -- Direct Voters +('rep'); -- 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.name IS 'The ID of this voting group.'; @@ -38,18 +38,18 @@ COMMENT ON COLUMN voting_group.name IS 'The ID of this voting group.'; CREATE TABLE voteplan ( - row_id SERIAL PRIMARY KEY, - objective_id INTEGER NOT NULL, - - id VARCHAR NOT NULL, - category TEXT NOT NULL, - encryption_key VARCHAR, - group_id TEXT, - token_id TEXT, - - 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(name) ON DELETE CASCADE + row_id SERIAL PRIMARY KEY, + objective_id INTEGER NOT NULL, + + id VARCHAR NOT NULL, + category TEXT NOT NULL, + encryption_key VARCHAR, + group_id TEXT, + token_id TEXT, + + 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 (name) ON DELETE CASCADE ); COMMENT ON TABLE voteplan IS 'All Vote plans.'; @@ -71,16 +71,18 @@ COMMENT ON COLUMN voteplan.group_id IS 'The identifier of voting power token use -- and each voteplan can contain multiple proposals. CREATE TABLE proposal_voteplan ( - row_id SERIAL PRIMARY KEY, - proposal_id INTEGER, - voteplan_id INTEGER, - bb_proposal_index BIGINT, + row_id SERIAL PRIMARY KEY, + proposal_id INTEGER, + voteplan_id INTEGER, + bb_proposal_index BIGINT, - FOREIGN KEY(proposal_id) REFERENCES proposal(row_id) ON DELETE CASCADE, - FOREIGN KEY(voteplan_id) REFERENCES voteplan(row_id) ON DELETE CASCADE + FOREIGN KEY (proposal_id) REFERENCES proposal (row_id) ON DELETE CASCADE, + FOREIGN KEY (voteplan_id) REFERENCES voteplan (row_id) ON DELETE CASCADE ); -CREATE UNIQUE INDEX proposal_voteplan_idx ON proposal_voteplan(proposal_id,voteplan_id,bb_proposal_index); +CREATE UNIQUE INDEX proposal_voteplan_idx ON proposal_voteplan ( + proposal_id, voteplan_id, bb_proposal_index +); COMMENT ON TABLE proposal_voteplan IS 'Table to link Proposals to Vote plans in a Many to Many relationship.'; COMMENT ON COLUMN proposal_voteplan.row_id IS 'Synthetic ID of this Voteplan/Proposal M-M relationship.'; diff --git a/catalyst-gateway/event-db/migrations/V6__snapshot_tables.sql b/catalyst-gateway/event-db/migrations/V6__snapshot_tables.sql index 1d0fe5f1227..7e8115b629c 100644 --- a/catalyst-gateway/event-db/migrations/V6__snapshot_tables.sql +++ b/catalyst-gateway/event-db/migrations/V6__snapshot_tables.sql @@ -3,115 +3,119 @@ -- Voting Power Snapshot Table CREATE TABLE snapshot ( - row_id SERIAL PRIMARY KEY, - event INTEGER NOT NULL UNIQUE, - as_at TIMESTAMP NOT NULL, - as_at_slotno INTEGER NOT NULL, - last_updated TIMESTAMP NOT NULL, - last_updated_slotno INTEGER NOT NULL, + row_id SERIAL PRIMARY KEY, + event INTEGER NOT NULL UNIQUE, + as_at TIMESTAMP NOT NULL, + as_at_slotno INTEGER NOT NULL, + last_updated TIMESTAMP NOT NULL, + last_updated_slotno INTEGER NOT NULL, - final BOOLEAN NOT NULL, + final BOOLEAN NOT NULL, - dbsync_snapshot_cmd TEXT NULL, - dbsync_snapshot_params JSONB NULL, - dbsync_snapshot_data BYTEA NULL, - dbsync_snapshot_error BYTEA NULL, - dbsync_snapshot_unregistered BYTEA NULL, + dbsync_snapshot_cmd TEXT NULL, + dbsync_snapshot_params JSONB NULL, + dbsync_snapshot_data BYTEA NULL, + dbsync_snapshot_error BYTEA NULL, + dbsync_snapshot_unregistered BYTEA NULL, - drep_data BYTEA NULL, + drep_data BYTEA NULL, - catalyst_snapshot_cmd TEXT NULL, - catalyst_snapshot_params JSONB NULL, - catalyst_snapshot_data BYTEA NULL, + catalyst_snapshot_cmd TEXT NULL, + catalyst_snapshot_params JSONB NULL, + catalyst_snapshot_data BYTEA NULL, - FOREIGN KEY(event) REFERENCES event(row_id) ON DELETE CASCADE + FOREIGN KEY (event) REFERENCES event (row_id) ON DELETE CASCADE ); COMMENT ON TABLE snapshot IS 'Raw snapshot data for an event. Only the latests snapshot per event is stored.'; -COMMENT ON COLUMN snapshot.event is 'The event id this snapshot was for.'; -COMMENT ON COLUMN snapshot.as_at is +COMMENT ON COLUMN snapshot.event IS 'The event id this snapshot was for.'; +COMMENT ON COLUMN snapshot.as_at IS 'The time the snapshot was collected from dbsync. This is the snapshot *DEADLINE*, i.e the time when registrations are final. (Should be the slot time the dbsync_snapshot_cmd was run against.)'; -COMMENT ON COLUMN snapshot.last_updated is +COMMENT ON COLUMN snapshot.last_updated IS 'The last time the snapshot was run (Should be the latest block time taken from dbsync just before the snapshot was run.)'; -COMMENT ON COLUMN snapshot.final is +COMMENT ON COLUMN snapshot.final IS 'Is the snapshot Final? No more updates will occur to this record once set.'; -COMMENT ON COLUMN snapshot.dbsync_snapshot_cmd is 'The name of the command run to collect the snapshot from dbsync.'; -COMMENT ON COLUMN snapshot.dbsync_snapshot_params is 'The parameters passed to the command, each parameter is a key and its value is the value of the parameter.'; -COMMENT ON COLUMN snapshot.dbsync_snapshot_data is +COMMENT ON COLUMN snapshot.dbsync_snapshot_cmd IS 'The name of the command run to collect the snapshot from dbsync.'; +COMMENT ON COLUMN snapshot.dbsync_snapshot_params IS 'The parameters passed to the command, each parameter is a key and its value is the value of the parameter.'; +COMMENT ON COLUMN snapshot.dbsync_snapshot_data IS 'The BROTLI COMPRESSED raw json result stored as BINARY from the dbsync snapshot. (This is JSON data but we store as raw text to prevent any processing of it, and BROTLI compress to save space).'; -COMMENT ON COLUMN snapshot.dbsync_snapshot_error is +COMMENT ON COLUMN snapshot.dbsync_snapshot_error IS 'The BROTLI COMPRESSED raw json errors stored as BINARY from the dbsync snapshot. (This is JSON data but we store as raw text to prevent any processing of it, and BROTLI compress to save space).'; -COMMENT ON COLUMN snapshot.dbsync_snapshot_unregistered is +COMMENT ON COLUMN snapshot.dbsync_snapshot_unregistered IS 'The BROTLI COMPRESSED unregistered voting power stored as BINARY from the dbsync snapshot. (This is JSON data but we store as raw text to prevent any processing of it, and BROTLI compress to save space).'; -COMMENT ON COLUMN snapshot.drep_data is +COMMENT ON COLUMN snapshot.drep_data IS 'The latest drep data obtained from GVC, and used in this snapshot calculation. Should be in a form directly usable by the `catalyst_snapshot_cmd` However, in order to save space this data is stored as BROTLI COMPRESSED BINARY.'; -COMMENT ON COLUMN snapshot.catalyst_snapshot_cmd is 'The actual name of the command run to produce the catalyst voting power snapshot.'; -COMMENT ON COLUMN snapshot.dbsync_snapshot_params is 'The parameters passed to the command, each parameter is a key and its value is the value of the parameter.'; -COMMENT ON COLUMN snapshot.catalyst_snapshot_data is +COMMENT ON COLUMN snapshot.catalyst_snapshot_cmd IS 'The actual name of the command run to produce the catalyst voting power snapshot.'; +COMMENT ON COLUMN snapshot.dbsync_snapshot_params IS 'The parameters passed to the command, each parameter is a key and its value is the value of the parameter.'; +COMMENT ON COLUMN snapshot.catalyst_snapshot_data IS 'The BROTLI COMPRESSED raw yaml result stored as BINARY from the catalyst snapshot calculation. (This is YAML data but we store as raw text to prevent any processing of it, and BROTLI compress to save space).'; -- voters CREATE TABLE voter ( - row_id SERIAL8 PRIMARY KEY, + row_id SERIAL8 PRIMARY KEY, - voting_key TEXT NOT NULL, - snapshot_id INTEGER NOT NULL, - voting_group TEXT NOT NULL, + voting_key TEXT NOT NULL, + snapshot_id INTEGER NOT NULL, + voting_group TEXT NOT NULL, - voting_power BIGINT NOT NULL, + voting_power BIGINT NOT NULL, - FOREIGN KEY(snapshot_id) REFERENCES snapshot(row_id) ON DELETE CASCADE + FOREIGN KEY (snapshot_id) REFERENCES snapshot (row_id) ON DELETE CASCADE ); -CREATE UNIQUE INDEX unique_voter_id on voter (voting_key, voting_group, snapshot_id); +CREATE UNIQUE INDEX unique_voter_id ON voter ( + voting_key, voting_group, snapshot_id +); COMMENT ON TABLE voter IS 'Voting Power for every voting key.'; -COMMENT ON COLUMN voter.voting_key is 'Either the voting key.'; -COMMENT ON COLUMN voter.snapshot_id is 'The ID of the snapshot this record belongs to.'; -COMMENT ON COLUMN voter.voting_group is 'The voter group the voter belongs to.'; -COMMENT ON COLUMN voter.voting_power is 'Calculated Voting Power associated with this key.'; +COMMENT ON COLUMN voter.voting_key IS 'Either the voting key.'; +COMMENT ON COLUMN voter.snapshot_id IS 'The ID of the snapshot this record belongs to.'; +COMMENT ON COLUMN voter.voting_group IS 'The voter group the voter belongs to.'; +COMMENT ON COLUMN voter.voting_power IS 'Calculated Voting Power associated with this key.'; -- contributions CREATE TABLE contribution ( - row_id SERIAL8 PRIMARY KEY, + row_id SERIAL8 PRIMARY KEY, - stake_public_key TEXT NOT NULL, - snapshot_id INTEGER NOT NULL, + stake_public_key TEXT NOT NULL, + snapshot_id INTEGER NOT NULL, - voting_key TEXT NULL, - voting_weight INTEGER NULL, - voting_key_idx INTEGER NULL, - value BIGINT NOT NULL, + voting_key TEXT NULL, + voting_weight INTEGER NULL, + voting_key_idx INTEGER NULL, + value BIGINT NOT NULL, - voting_group TEXT NOT NULL, + voting_group TEXT NOT NULL, - -- each unique stake_public_key should have the same reward_address - reward_address TEXT NULL, + -- each unique stake_public_key should have the same reward_address + reward_address TEXT NULL, - FOREIGN KEY(snapshot_id) REFERENCES snapshot(row_id) ON DELETE CASCADE + FOREIGN KEY (snapshot_id) REFERENCES snapshot (row_id) ON DELETE CASCADE ); -CREATE UNIQUE INDEX unique_contribution_id ON contribution (stake_public_key, voting_key, voting_group, snapshot_id); +CREATE UNIQUE INDEX unique_contribution_id ON contribution ( + stake_public_key, voting_key, voting_group, snapshot_id +); COMMENT ON TABLE contribution IS 'Individual Contributions from stake public keys to voting keys.'; -COMMENT ON COLUMN contribution.row_id is 'Synthetic Unique Row Key'; +COMMENT ON COLUMN contribution.row_id IS 'Synthetic Unique Row Key'; COMMENT ON COLUMN contribution.stake_public_key IS 'The voters Stake Public Key'; COMMENT ON COLUMN contribution.snapshot_id IS 'The snapshot this contribution was recorded from.'; diff --git a/catalyst-gateway/event-db/migrations/V7__vote_tables.sql b/catalyst-gateway/event-db/migrations/V7__vote_tables.sql index 5ac1c64d26b..ce92bbe57ac 100644 --- a/catalyst-gateway/event-db/migrations/V7__vote_tables.sql +++ b/catalyst-gateway/event-db/migrations/V7__vote_tables.sql @@ -3,31 +3,31 @@ -- vote storage (replicates on-chain data for easy querying) CREATE TABLE ballot ( - row_id SERIAL8 PRIMARY KEY, - objective INTEGER NOT NULL, - proposal INTEGER NULL, + row_id SERIAL8 PRIMARY KEY, + objective INTEGER NOT NULL, + proposal INTEGER NULL, - voter INTEGER NOT NULL, - fragment_id TEXT NOT NULL, - cast_at TIMESTAMP NOT NULL, - choice SMALLINT NULL, - raw_fragment BYTEA NOT NULL, + voter INTEGER NOT NULL, + fragment_id TEXT NOT NULL, + cast_at TIMESTAMP NOT NULL, + choice SMALLINT NULL, + raw_fragment BYTEA NOT NULL, - FOREIGN KEY(voter) REFERENCES voter(row_id) ON DELETE CASCADE, - FOREIGN KEY(objective) REFERENCES objective(row_id) ON DELETE CASCADE, - FOREIGN KEY(proposal) REFERENCES proposal(row_id) ON DELETE CASCADE + FOREIGN KEY (voter) REFERENCES voter (row_id) ON DELETE CASCADE, + FOREIGN KEY (objective) REFERENCES objective (row_id) ON DELETE CASCADE, + FOREIGN KEY (proposal) REFERENCES proposal (row_id) ON DELETE CASCADE ); -CREATE UNIQUE INDEX ballot_proposal_idx ON ballot(proposal,fragment_id); -CREATE UNIQUE INDEX ballot_objective_idx ON ballot(objective,fragment_id); +CREATE UNIQUE INDEX ballot_proposal_idx ON ballot (proposal, fragment_id); +CREATE UNIQUE INDEX ballot_objective_idx ON ballot (objective, fragment_id); COMMENT ON TABLE ballot IS 'All Ballots cast on an event.'; -COMMENT ON COLUMN ballot.fragment_id is 'Unique ID of this Ballot'; -COMMENT ON COLUMN ballot.voter is 'Reference to the Voter who cast the ballot'; -COMMENT ON COLUMN ballot.objective is 'Reference to the Objective the ballot was for.'; -COMMENT ON COLUMN ballot.proposal is +COMMENT ON COLUMN ballot.fragment_id IS 'Unique ID of this Ballot'; +COMMENT ON COLUMN ballot.voter IS 'Reference to the Voter who cast the ballot'; +COMMENT ON COLUMN ballot.objective IS 'Reference to the Objective the ballot was for.'; +COMMENT ON COLUMN ballot.proposal IS 'Reference to the Proposal the ballot was for. May be NULL if this ballot covers ALL proposals in the challenge.'; -COMMENT ON COLUMN ballot.cast_at is 'When this ballot was recorded as properly cast'; -COMMENT ON COLUMN ballot.choice is 'If a public vote, the choice on the ballot, otherwise NULL.'; -COMMENT ON COLUMN ballot.raw_fragment is 'The raw ballot record.'; +COMMENT ON COLUMN ballot.cast_at IS 'When this ballot was recorded as properly cast'; +COMMENT ON COLUMN ballot.choice IS 'If a public vote, the choice on the ballot, otherwise NULL.'; +COMMENT ON COLUMN ballot.raw_fragment IS 'The raw ballot record.'; diff --git a/catalyst-gateway/event-db/migrations/V8__catalyst_automation.sql b/catalyst-gateway/event-db/migrations/V8__catalyst_automation.sql index 4be1b69fa79..dada1e5f450 100644 --- a/catalyst-gateway/event-db/migrations/V8__catalyst_automation.sql +++ b/catalyst-gateway/event-db/migrations/V8__catalyst_automation.sql @@ -3,15 +3,15 @@ -- Voting Nodes Table - Defines nodes in the network -- This table is looked up by hostname and event CREATE TABLE voting_node ( - hostname TEXT NOT NULL, - event INTEGER NOT NULL, + hostname TEXT NOT NULL, + event INTEGER NOT NULL, - pubkey TEXT NOT NULL, - seckey TEXT NOT NULL, - netkey TEXT NOT NULL, + pubkey TEXT NOT NULL, + seckey TEXT NOT NULL, + netkey TEXT NOT NULL, - PRIMARY KEY (hostname, event), - FOREIGN KEY(event) REFERENCES event(row_id) ON DELETE CASCADE + PRIMARY KEY (hostname, event), + FOREIGN KEY (event) REFERENCES event (row_id) ON DELETE CASCADE ); COMMENT ON TABLE voting_node IS @@ -27,49 +27,49 @@ COMMENT ON COLUMN voting_node.netkey IS 'Encrypted Ed25519 secret key for the no -- Tally Committee Table - Stores data about the tally committee per voting event -- This table is looked up by event CREATE TABLE tally_committee ( - row_id SERIAL PRIMARY KEY, + row_id SERIAL PRIMARY KEY, - event INTEGER NOT NULL UNIQUE, + event INTEGER NOT NULL UNIQUE, - committee_pk TEXT NOT NULL, - committee_id TEXT NOT NULL, - member_crs TEXT, - election_key TEXT, + committee_pk TEXT NOT NULL, + committee_id TEXT NOT NULL, + member_crs TEXT, + election_key TEXT, - FOREIGN KEY(event) REFERENCES event(row_id) ON DELETE CASCADE + FOREIGN KEY (event) REFERENCES event (row_id) ON DELETE CASCADE ); COMMENT ON TABLE tally_committee IS 'Table for storing data about the tally committee per voting event.'; COMMENT ON COLUMN tally_committee.row_id IS 'Unique ID for this committee member for this event.'; -COMMENT ON COLUMN tally_committee.event IS 'The event this committee member is for.'; -COMMENT ON COLUMN tally_committee.committee_pk IS 'Encrypted private key for the committee wallet. This key can be used to get the committee public address.'; -COMMENT ON COLUMN tally_committee.committee_id IS 'The hex-encoded public key for the committee wallet.'; -COMMENT ON COLUMN tally_committee.member_crs IS 'Encrypted Common Reference String shared in the creation of every set of committee member keys.'; -COMMENT ON COLUMN tally_committee.election_key IS 'Public key generated with all committee member public keys, and is used to encrypt votes. NULL if the event.committee_size is 0.'; +COMMENT ON COLUMN tally_committee.event IS 'The event this committee member is for.'; +COMMENT ON COLUMN tally_committee.committee_pk IS 'Encrypted private key for the committee wallet. This key can be used to get the committee public address.'; +COMMENT ON COLUMN tally_committee.committee_id IS 'The hex-encoded public key for the committee wallet.'; +COMMENT ON COLUMN tally_committee.member_crs IS 'Encrypted Common Reference String shared in the creation of every set of committee member keys.'; +COMMENT ON COLUMN tally_committee.election_key IS 'Public key generated with all committee member public keys, and is used to encrypt votes. NULL if the event.committee_size is 0.'; -- Committee Member Table - Stores data about the tally committee members -- This table is looked up by committee CREATE TABLE committee_member ( - row_id SERIAL PRIMARY KEY, + row_id SERIAL PRIMARY KEY, - committee INTEGER NOT NULL, + committee INTEGER NOT NULL, - member_index INTEGER NOT NULL, - threshold INTEGER NOT NULL, - comm_pk TEXT NOT NULL, - comm_sk TEXT NOT NULL, - member_pk TEXT NOT NULL, - member_sk TEXT NOT NULL, + member_index INTEGER NOT NULL, + threshold INTEGER NOT NULL, + comm_pk TEXT NOT NULL, + comm_sk TEXT NOT NULL, + member_pk TEXT NOT NULL, + member_sk TEXT NOT NULL, - FOREIGN KEY(committee) REFERENCES tally_committee(row_id) + FOREIGN KEY (committee) REFERENCES tally_committee (row_id) ); COMMENT ON TABLE committee_member IS 'Table for storing data about the tally committee members.'; COMMENT ON COLUMN committee_member.row_id IS 'Unique ID for this committee member for this event.'; COMMENT ON COLUMN committee_member.member_index IS 'the zero-based index of the member, ranging from 0 <= index < committee_size.'; COMMENT ON COLUMN committee_member.committee IS 'The committee this member belongs to.'; -COMMENT ON COLUMN committee_member.comm_pk IS 'Committee member communication public key.'; -COMMENT ON COLUMN committee_member.comm_sk IS 'Encrypted committee member communication secret key.'; -COMMENT ON COLUMN committee_member.member_pk IS 'Committee member public key'; -COMMENT ON COLUMN committee_member.member_sk IS 'Encrypted committee member secret key'; +COMMENT ON COLUMN committee_member.comm_pk IS 'Committee member communication public key.'; +COMMENT ON COLUMN committee_member.comm_sk IS 'Encrypted committee member communication secret key.'; +COMMENT ON COLUMN committee_member.member_pk IS 'Committee member public key'; +COMMENT ON COLUMN committee_member.member_sk IS 'Encrypted committee member secret key'; diff --git a/catalyst-gateway/event-db/migrations/V9__moderation_stage.sql b/catalyst-gateway/event-db/migrations/V9__moderation_stage.sql index 7afaa756968..1d6c923d382 100644 --- a/catalyst-gateway/event-db/migrations/V9__moderation_stage.sql +++ b/catalyst-gateway/event-db/migrations/V9__moderation_stage.sql @@ -8,8 +8,8 @@ CREATE TABLE moderation_allocation ( review_id INTEGER NOT NULL, user_id INTEGER NOT NULL, - FOREIGN KEY (review_id) REFERENCES proposal_review(row_id) ON DELETE CASCADE, - FOREIGN KEY (user_id) REFERENCES config(row_id) ON DELETE CASCADE + FOREIGN KEY (review_id) REFERENCES proposal_review (row_id) ON DELETE CASCADE, + FOREIGN KEY (user_id) REFERENCES config (row_id) ON DELETE CASCADE ); @@ -29,8 +29,8 @@ CREATE TABLE moderation ( rationale VARCHAR, UNIQUE (review_id, user_id), - FOREIGN KEY (review_id) REFERENCES proposal_review(row_id) ON DELETE CASCADE, - FOREIGN KEY (user_id) REFERENCES config(row_id) ON DELETE CASCADE + FOREIGN KEY (review_id) REFERENCES proposal_review (row_id) ON DELETE CASCADE, + FOREIGN KEY (user_id) REFERENCES config (row_id) ON DELETE CASCADE ); @@ -39,4 +39,4 @@ COMMENT ON COLUMN moderation.row_id IS 'Synthetic ID of this moderation.'; COMMENT ON COLUMN moderation.review_id IS 'The review the moderation is related to.'; COMMENT ON COLUMN moderation.user_id IS 'The user the moderation is submitted from.'; COMMENT ON COLUMN moderation.classification IS 'The value used to describe the moderation (e.g. 0: excluded, 1: included).'; -COMMENT ON COLUMN moderation.rationale IS 'The rationale for the given classification.'; \ No newline at end of file +COMMENT ON COLUMN moderation.rationale IS 'The rationale for the given classification.'; diff --git a/catalyst-gateway/event-db/setup/dev-db.docker-compose.yml b/catalyst-gateway/event-db/setup/dev-db.docker-compose.yml deleted file mode 100644 index 54f305cbe96..00000000000 --- a/catalyst-gateway/event-db/setup/dev-db.docker-compose.yml +++ /dev/null @@ -1,45 +0,0 @@ -# Start a local development postgres-14 DB -# Default username/password = postgres:postgres -version: "3.1" - -services: - db: - image: postgres:14 - restart: always - environment: - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - POSTGRES_DB: CatalystEventDev - healthcheck: - test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"] - interval: 2s - timeout: 5s - retries: 10 - ports: - - 5432:5432 - - migrations: - image: migrations:latest - environment: - # Required environment variables for migrations - - DB_HOST=db - - DB_PORT=5432 - - DB_NAME=CatalystEventDev - - DB_SUPERUSER=postgres - - DB_SUPERUSER_PASSWORD=postgres - - DB_USER=catalyst-event-dev - - DB_USER_PASSWORD=CHANGE_ME - - ADMIN_ROLE_PASSWORD=CHANGE_ME - - ADMIN_USER_PASSWORD=CHANGE_ME - - ANON_ROLE_PASSWORD=CHANGE_ME - depends_on: - db: - condition: service_healthy - - adminer: - image: adminer - restart: always - depends_on: - - db - ports: - - 8080:8080 diff --git a/catalyst-gateway/event-db/setup/setup-db.sql b/catalyst-gateway/event-db/setup/setup-db.sql deleted file mode 100644 index 6e661873943..00000000000 --- a/catalyst-gateway/event-db/setup/setup-db.sql +++ /dev/null @@ -1,57 +0,0 @@ --- Initialize the Project Catalyst Event Database. - --- This script requires a number of variables to be set. --- They will default if not set externally. --- These variables can be set on the "psql" command line. --- Passwords may optionally be set by ENV Vars. --- This script requires "psql" is run inside a POSIX compliant shell. - --- VARIABLES: - --- The name of the Database to connect to. -\if :{?dbName} \else - \set dbName CatalystEventDev -\endif - --- The description of the database. -\if :{?dbDescription} \else - \set dbDescription 'Catalyst Event DB' -\endif - - --- The db user with full permissions on the DB. -\if :{?dbUser} \else - \set dbUser 'catalyst-event-dev' -\endif - --- The db users password. -\if :{?dbUserPw} \else - \set dbUserPw `echo ${DB_USER_PW:-CHANGE_ME}` -\endif - --- DISPLAY ALL VARIABLES -\echo VARIABLES: -\echo -> dbName ................. = :dbName -\echo -> dbDescription .......... = :dbDescription -\echo -> dbUser ................. = :dbUser -\echo -> dbUserPw / $DB_USER_PW . = :dbUserPw - - --- Cleanup if we already ran this before. -DROP DATABASE IF EXISTS :"dbName"; - -DROP USER IF EXISTS :"dbUser"; - --- Create the test user we will use with the local Catalyst-Event dev database. -CREATE USER :"dbUser" WITH PASSWORD :'dbUserPw'; - --- Privileges for this user/role. -ALTER DEFAULT privileges REVOKE EXECUTE ON functions FROM public; - -ALTER DEFAULT privileges IN SCHEMA public REVOKE EXECUTE ON functions FROM :"dbUser"; - --- Create the database. -CREATE DATABASE :"dbName" WITH OWNER :"dbUser"; - -COMMENT ON DATABASE :"dbName" IS :'dbDescription'; - diff --git a/catalyst-gateway/event-db/stage_data/dev/00001_testfund_event.sql b/catalyst-gateway/event-db/stage_data/dev/00001_testfund_event.sql index 17e365b4f49..e73fc5ad805 100644 --- a/catalyst-gateway/event-db/stage_data/dev/00001_testfund_event.sql +++ b/catalyst-gateway/event-db/stage_data/dev/00001_testfund_event.sql @@ -1,54 +1,54 @@ -- F10 INSERT INTO event ( - row_id, - name, - description, - registration_snapshot_time, - snapshot_start, - voting_power_threshold, - max_voting_power_pct, - review_rewards, - start_time, - end_time, - insight_sharing_start, - proposal_submission_start, - refine_proposals_start, - finalize_proposals_start, - proposal_assessment_start, - assessment_qa_start, - voting_start, - voting_end, - tallying_end, - block0, - block0_hash, - committee_size, - committee_threshold, - extra, - cast_to + row_id, + name, + description, + registration_snapshot_time, + snapshot_start, + voting_power_threshold, + max_voting_power_pct, + review_rewards, + start_time, + end_time, + insight_sharing_start, + proposal_submission_start, + refine_proposals_start, + finalize_proposals_start, + proposal_assessment_start, + assessment_qa_start, + voting_start, + voting_end, + tallying_end, + block0, + block0_hash, + committee_size, + committee_threshold, + extra, + cast_to ) VALUES ( - 0, - 'Test Fund', - 'Catalyst Dev Environment - Test Fund', - '1970-01-01 00:00:00', -- Registration Snapshot Time - '1970-01-01 00:00:00', -- Snapshot Start. - 450000000, -- Voting Power Threshold - 1, -- Max Voting Power PCT - NULL, -- Review Rewards - '1970-01-01 00:00:00', -- Start Time - '1970-01-01 00:00:00', -- End Time - '1970-01-01 00:00:00', -- Insight Sharing Start - '1970-01-01 00:00:00', -- Proposal Submission Start - '1970-01-01 00:00:00', -- Refine Proposals Start - '1970-01-01 00:00:00', -- Finalize Proposals Start - '1970-01-01 00:00:00', -- Proposal Assessment Start - '1970-01-01 00:00:00', -- Assessment QA Start - '1970-01-01 00:00:00', -- Voting Starts - '1970-01-01 00:00:00', -- Voting Ends - '1970-01-01 00:00:00', -- Tallying Ends - NULL, -- Block 0 Data - NULL, -- Block 0 Hash - 1, -- Committee Size - 1, -- Committee Threshold - NULL, -- Extra - NULL -- Cast to -); \ No newline at end of file + 0, + 'Test Fund', + 'Catalyst Dev Environment - Test Fund', + '1970-01-01 00:00:00', -- Registration Snapshot Time + '1970-01-01 00:00:00', -- Snapshot Start. + 450000000, -- Voting Power Threshold + 1, -- Max Voting Power PCT + NULL, -- Review Rewards + '1970-01-01 00:00:00', -- Start Time + '1970-01-01 00:00:00', -- End Time + '1970-01-01 00:00:00', -- Insight Sharing Start + '1970-01-01 00:00:00', -- Proposal Submission Start + '1970-01-01 00:00:00', -- Refine Proposals Start + '1970-01-01 00:00:00', -- Finalize Proposals Start + '1970-01-01 00:00:00', -- Proposal Assessment Start + '1970-01-01 00:00:00', -- Assessment QA Start + '1970-01-01 00:00:00', -- Voting Starts + '1970-01-01 00:00:00', -- Voting Ends + '1970-01-01 00:00:00', -- Tallying Ends + NULL, -- Block 0 Data + NULL, -- Block 0 Hash + 1, -- Committee Size + 1, -- Committee Threshold + NULL, -- Extra + NULL -- Cast to +); diff --git a/catalyst-gateway/event-db/stage_data/dev/00002_testfund_ideascale_params.sql b/catalyst-gateway/event-db/stage_data/dev/00002_testfund_ideascale_params.sql index 98fe850bf03..52de83f25b1 100644 --- a/catalyst-gateway/event-db/stage_data/dev/00002_testfund_ideascale_params.sql +++ b/catalyst-gateway/event-db/stage_data/dev/00002_testfund_ideascale_params.sql @@ -1,9 +1,9 @@ -- Define F10 IdeaScale parameters. INSERT INTO config (id, id2, id3, value) VALUES ( - 'ideascale', - '0', - '', - '{ + 'ideascale', + '0', + '', + '{ "group_id": 37429, "review_stage_ids": [171], "nr_allocations": [1, 1], @@ -52,8 +52,8 @@ INSERT INTO config (id, id2, id3, value) VALUES ( -- Use F10 params for event with row_id = 10. INSERT INTO config (id, id2, id3, value) VALUES ( - 'event', - 'ideascale_params', - '0', - '{"params_id": "TestFund"}' + 'event', + 'ideascale_params', + '0', + '{"params_id": "TestFund"}' ); diff --git a/catalyst-gateway/event-db/stage_data/testnet/00001_fund10_event.sql b/catalyst-gateway/event-db/stage_data/testnet/00001_fund10_event.sql index 8b6f0cb6c36..8c243f380d2 100644 --- a/catalyst-gateway/event-db/stage_data/testnet/00001_fund10_event.sql +++ b/catalyst-gateway/event-db/stage_data/testnet/00001_fund10_event.sql @@ -1,54 +1,54 @@ -- F10 INSERT INTO event ( - row_id, - name, - description, - registration_snapshot_time, - snapshot_start, - voting_power_threshold, - max_voting_power_pct, - review_rewards, - start_time, - end_time, - insight_sharing_start, - proposal_submission_start, - refine_proposals_start, - finalize_proposals_start, - proposal_assessment_start, - assessment_qa_start, - voting_start, - voting_end, - tallying_end, - block0, - block0_hash, - committee_size, - committee_threshold, - extra, - cast_to + row_id, + name, + description, + registration_snapshot_time, + snapshot_start, + voting_power_threshold, + max_voting_power_pct, + review_rewards, + start_time, + end_time, + insight_sharing_start, + proposal_submission_start, + refine_proposals_start, + finalize_proposals_start, + proposal_assessment_start, + assessment_qa_start, + voting_start, + voting_end, + tallying_end, + block0, + block0_hash, + committee_size, + committee_threshold, + extra, + cast_to ) VALUES ( - 10, - 'Fund 10', - 'Catalyst Testnet - Fund 10', - '2023-08-18 21:00:00', -- Registration Snapshot Time - '2023-08-23 22:00:00', -- Snapshot Start. - 450000000, -- Voting Power Threshold - 1, -- Max Voting Power PCT - NULL, -- Review Rewards - '2023-06-16 19:56:00', -- Start Time - '2023-09-18 00:00:00', -- End Time - '2023-06-22 00:00:00', -- Insight Sharing Start - '2023-06-22 00:00:00', -- Proposal Submission Start - '2023-06-22 00:00:00', -- Refine Proposals Start - '2023-07-13 00:00:00', -- Finalize Proposals Start - '2023-07-20 00:00:00', -- Proposal Assessment Start - '2023-08-10 00:00:00', -- Assessment QA Start - '2023-08-31 11:00:00', -- Voting Starts - '2023-09-14 11:00:00', -- Voting Ends - '2023-09-18 11:00:00', -- Tallying Ends - NULL, -- Block 0 Data - NULL, -- Block 0 Hash - 1, -- Committee Size - 1, -- Committee Threshold - NULL, -- Extra - NULL -- Cast to -); \ No newline at end of file + 10, + 'Fund 10', + 'Catalyst Testnet - Fund 10', + '2023-08-18 21:00:00', -- Registration Snapshot Time + '2023-08-23 22:00:00', -- Snapshot Start. + 450000000, -- Voting Power Threshold + 1, -- Max Voting Power PCT + NULL, -- Review Rewards + '2023-06-16 19:56:00', -- Start Time + '2023-09-18 00:00:00', -- End Time + '2023-06-22 00:00:00', -- Insight Sharing Start + '2023-06-22 00:00:00', -- Proposal Submission Start + '2023-06-22 00:00:00', -- Refine Proposals Start + '2023-07-13 00:00:00', -- Finalize Proposals Start + '2023-07-20 00:00:00', -- Proposal Assessment Start + '2023-08-10 00:00:00', -- Assessment QA Start + '2023-08-31 11:00:00', -- Voting Starts + '2023-09-14 11:00:00', -- Voting Ends + '2023-09-18 11:00:00', -- Tallying Ends + NULL, -- Block 0 Data + NULL, -- Block 0 Hash + 1, -- Committee Size + 1, -- Committee Threshold + NULL, -- Extra + NULL -- Cast to +); diff --git a/catalyst-gateway/event-db/stage_data/testnet/00002_fund10_ideascale_params.sql b/catalyst-gateway/event-db/stage_data/testnet/00002_fund10_ideascale_params.sql index 81156fe5b9f..8957541401f 100644 --- a/catalyst-gateway/event-db/stage_data/testnet/00002_fund10_ideascale_params.sql +++ b/catalyst-gateway/event-db/stage_data/testnet/00002_fund10_ideascale_params.sql @@ -1,9 +1,9 @@ -- Define F10 IdeaScale parameters. INSERT INTO config (id, id2, id3, value) VALUES ( - 'ideascale', - '10', - '', - '{ + 'ideascale', + '10', + '', + '{ "group_id": 31051, "review_stage_ids": [143, 145], "nr_allocations": [30, 80], @@ -52,8 +52,8 @@ INSERT INTO config (id, id2, id3, value) VALUES ( -- Use F10 params for event with row_id = 10. INSERT INTO config (id, id2, id3, value) VALUES ( - 'event', - 'ideascale_params', - '10', - '{"params_id": "F10"}' + 'event', + 'ideascale_params', + '10', + '{"params_id": "F10"}' ); diff --git a/catalyst-gateway/event-db/test_data/01_event_table.sql b/catalyst-gateway/event-db/test_data/01_event_table.sql index 0731cd32641..37fa58c55fa 100644 --- a/catalyst-gateway/event-db/test_data/01_event_table.sql +++ b/catalyst-gateway/event-db/test_data/01_event_table.sql @@ -1,47 +1,108 @@ INSERT INTO event -(row_id, name, description, registration_snapshot_time, snapshot_start, - voting_power_threshold, max_voting_power_pct, start_time, end_time, insight_sharing_start, - proposal_submission_start, refine_proposals_start, finalize_proposals_start, proposal_assessment_start, assessment_qa_start, - voting_start, voting_end, tallying_end, block0, block0_hash, committee_size, committee_threshold) +( + row_id, name, description, registration_snapshot_time, snapshot_start, + voting_power_threshold, + max_voting_power_pct, + start_time, + end_time, + insight_sharing_start, + proposal_submission_start, + refine_proposals_start, + finalize_proposals_start, + proposal_assessment_start, + assessment_qa_start, + voting_start, + voting_end, + tallying_end, + block0, + block0_hash, + committee_size, + committee_threshold +) VALUES -(1, - 'Test Fund 1', 'Test Fund 1 description', - '2020-03-31 12:00:00', '2020-03-31 12:00:00', 1, 100, - '2020-05-01 12:00:00', '2020-06-01 12:00:00', - '2020-03-01 12:00:00', '2020-03-01 12:00:00', '2020-03-01 12:00:00', '2020-03-01 12:00:00', '2020-03-01 12:00:00', '2020-03-01 12:00:00', '2020-05-01 12:00:00', '2020-06-01 12:00:00', '2020-07-01 12:00:00', - 'x0000000000000000000000000000000000000000000000000000000000000000', 'x0000000000000000000000000000000000000000000000000000000000000000', - 4, 4), +( + 1, + 'Test Fund 1', 'Test Fund 1 description', + '2020-03-31 12:00:00', '2020-03-31 12:00:00', 1, 100, + '2020-05-01 12:00:00', '2020-06-01 12:00:00', + '2020-03-01 12:00:00', + '2020-03-01 12:00:00', + '2020-03-01 12:00:00', + '2020-03-01 12:00:00', + '2020-03-01 12:00:00', + '2020-03-01 12:00:00', + '2020-05-01 12:00:00', + '2020-06-01 12:00:00', + '2020-07-01 12:00:00', + 'x0000000000000000000000000000000000000000000000000000000000000000', + 'x0000000000000000000000000000000000000000000000000000000000000000', + 4, 4 +), -(2, - 'Test Fund 2', 'Test Fund 2 description', - '2021-03-31 12:00:00', '2021-03-31 12:00:00', 1, 100, - '2021-05-01 12:00:00', '2021-06-01 12:00:00', - '2021-03-01 12:00:00', '2021-03-01 12:00:00', '2021-03-01 12:00:00', '2021-03-01 12:00:00', '2021-03-01 12:00:00', '2021-03-01 12:00:00', '2021-05-01 12:00:00', '2021-06-01 12:00:00', '2021-07-01 12:00:00', - 'x0000000000000000000000000000000000000000000000000000000000000000', 'x0000000000000000000000000000000000000000000000000000000000000000', - 5, 5), +( + 2, + 'Test Fund 2', 'Test Fund 2 description', + '2021-03-31 12:00:00', '2021-03-31 12:00:00', 1, 100, + '2021-05-01 12:00:00', '2021-06-01 12:00:00', + '2021-03-01 12:00:00', + '2021-03-01 12:00:00', + '2021-03-01 12:00:00', + '2021-03-01 12:00:00', + '2021-03-01 12:00:00', + '2021-03-01 12:00:00', + '2021-05-01 12:00:00', + '2021-06-01 12:00:00', + '2021-07-01 12:00:00', + 'x0000000000000000000000000000000000000000000000000000000000000000', + 'x0000000000000000000000000000000000000000000000000000000000000000', + 5, 5 +), -(3, - 'Test Fund 3', 'Test Fund 3 description', - '2022-03-31 12:00:00', '2022-03-31 12:00:00', 1, 100, - '2022-05-01 12:00:00', '2022-06-01 12:00:00', - '2022-03-01 12:00:00', '2022-03-01 12:00:00', '2022-03-01 12:00:00', '2022-03-01 12:00:00', '2022-03-01 12:00:00', '2022-03-01 12:00:00', '2022-05-01 12:00:00', '2022-06-01 12:00:00', '2022-07-01 12:00:00', - 'x0000000000000000000000000000000000000000000000000000000000000000', 'x0000000000000000000000000000000000000000000000000000000000000000', - 6, 6), +( + 3, + 'Test Fund 3', 'Test Fund 3 description', + '2022-03-31 12:00:00', '2022-03-31 12:00:00', 1, 100, + '2022-05-01 12:00:00', '2022-06-01 12:00:00', + '2022-03-01 12:00:00', + '2022-03-01 12:00:00', + '2022-03-01 12:00:00', + '2022-03-01 12:00:00', + '2022-03-01 12:00:00', + '2022-03-01 12:00:00', + '2022-05-01 12:00:00', + '2022-06-01 12:00:00', + '2022-07-01 12:00:00', + 'x0000000000000000000000000000000000000000000000000000000000000000', + 'x0000000000000000000000000000000000000000000000000000000000000000', + 6, 6 +), -(4, - 'Test Fund 4', 'Test Fund 4 description', - '2022-03-31 12:00:00', '2022-03-31 12:00:00', 1, 100, - '2022-05-01 12:00:00', '2024-06-01 12:00:00', - '2022-03-01 12:00:00', '2022-03-01 12:00:00', '2022-03-01 12:00:00', '2022-03-01 12:00:00', '2022-03-01 12:00:00', '2022-03-01 12:00:00', '2022-05-01 12:00:00', '2024-06-01 12:00:00', '2024-07-01 12:00:00', - 'x0000000000000000000000000000000000000000000000000000000000000000', 'x0000000000000000000000000000000000000000000000000000000000000000', - 6, 6), +( + 4, + 'Test Fund 4', 'Test Fund 4 description', + '2022-03-31 12:00:00', '2022-03-31 12:00:00', 1, 100, + '2022-05-01 12:00:00', '2024-06-01 12:00:00', + '2022-03-01 12:00:00', + '2022-03-01 12:00:00', + '2022-03-01 12:00:00', + '2022-03-01 12:00:00', + '2022-03-01 12:00:00', + '2022-03-01 12:00:00', + '2022-05-01 12:00:00', + '2024-06-01 12:00:00', + '2024-07-01 12:00:00', + 'x0000000000000000000000000000000000000000000000000000000000000000', + 'x0000000000000000000000000000000000000000000000000000000000000000', + 6, 6 +), - (5, - 'Test Fund 5', 'Test Fund 5 description', - NULL, NULL, NULL, NULL, - NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, - 6, 6); - \ No newline at end of file +( + 5, + 'Test Fund 5', 'Test Fund 5 description', + NULL, NULL, NULL, NULL, + NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, + 6, 6 +); diff --git a/catalyst-gateway/event-db/test_data/02_snapshot_table.sql b/catalyst-gateway/event-db/test_data/02_snapshot_table.sql index e0b22ff34d8..1be27bd34c3 100644 --- a/catalyst-gateway/event-db/test_data/02_snapshot_table.sql +++ b/catalyst-gateway/event-db/test_data/02_snapshot_table.sql @@ -1,4 +1,3 @@ - INSERT INTO snapshot (row_id, event, as_at, as_at_slotno, last_updated, last_updated_slotno, final) VALUES diff --git a/catalyst-gateway/event-db/test_data/03_voter_table.sql b/catalyst-gateway/event-db/test_data/03_voter_table.sql index d4711f245c8..5737a6d5d07 100644 --- a/catalyst-gateway/event-db/test_data/03_voter_table.sql +++ b/catalyst-gateway/event-db/test_data/03_voter_table.sql @@ -1,6 +1,6 @@ -INSERT INTO voter +INSERT INTO voter (row_id, voting_key, snapshot_id, voting_group, voting_power) -VALUES +VALUES (1, 'voting_key_1', 1, 'rep', 250), (2, 'voting_key_2', 1, 'rep', 150), (3, 'voting_key_3', 1, 'direct', 350), diff --git a/catalyst-gateway/event-db/test_data/04_contribution_table.sql b/catalyst-gateway/event-db/test_data/04_contribution_table.sql index 7004f9d83db..9fb689a12de 100644 --- a/catalyst-gateway/event-db/test_data/04_contribution_table.sql +++ b/catalyst-gateway/event-db/test_data/04_contribution_table.sql @@ -1,23 +1,213 @@ -INSERT INTO contribution -(row_id, stake_public_key, snapshot_id, voting_key, voting_weight, voting_key_idx, value, voting_group, reward_address) -VALUES -(1, 'stake_public_key_1', 1, 'voting_key_1', 1, 1, 140, 'rep', 'addrr_reward_address_1'), -(2, 'stake_public_key_2', 1, 'voting_key_1', 1, 1, 110, 'rep', 'reward_address_2'), -(3, 'stake_public_key_1', 1, 'voting_key_2', 1, 1, 100, 'rep', 'reward_address_1'), -(4, 'stake_public_key_3', 1, 'voting_key_2', 1, 1, 50, 'rep', 'reward_address_3'), -(5, 'stake_public_key_4', 1, 'voting_key_3', 1, 1, 350, 'direct', 'reward_address_4'), -(6, 'stake_public_key_5', 1, 'voting_key_5', 1, 1, 250, 'direct', 'reward_address_5'), +INSERT INTO contribution +( + row_id, + stake_public_key, + snapshot_id, + voting_key, + voting_weight, + voting_key_idx, + value, + voting_group, + reward_address +) +VALUES +( + 1, + 'stake_public_key_1', + 1, + 'voting_key_1', + 1, + 1, + 140, + 'rep', + 'addrr_reward_address_1' +), +( + 2, + 'stake_public_key_2', + 1, + 'voting_key_1', + 1, + 1, + 110, + 'rep', + 'reward_address_2' +), +( + 3, + 'stake_public_key_1', + 1, + 'voting_key_2', + 1, + 1, + 100, + 'rep', + 'reward_address_1' +), +( + 4, + 'stake_public_key_3', + 1, + 'voting_key_2', + 1, + 1, + 50, + 'rep', + 'reward_address_3' +), +( + 5, + 'stake_public_key_4', + 1, + 'voting_key_3', + 1, + 1, + 350, + 'direct', + 'reward_address_4' +), +( + 6, + 'stake_public_key_5', + 1, + 'voting_key_5', + 1, + 1, + 250, + 'direct', + 'reward_address_5' +), -(7, 'stake_public_key_1', 2, 'voting_key_1', 1, 1, 140, 'rep', 'addrr_reward_address_1'), -(8, 'stake_public_key_2', 2, 'voting_key_1', 1, 1, 110, 'rep', 'reward_address_2'), -(9, 'stake_public_key_1', 2, 'voting_key_2', 1, 1, 100, 'rep', 'addrr_reward_address_1'), -(10, 'stake_public_key_3', 2, 'voting_key_2', 1, 1, 50, 'rep', 'reward_address_3'), -(11, 'stake_public_key_4', 2, 'voting_key_3', 1, 1, 350, 'direct', 'reward_address_4'), -(12, 'stake_public_key_5', 2, 'voting_key_5', 1, 1, 250, 'direct', 'reward_address_5'), +( + 7, + 'stake_public_key_1', + 2, + 'voting_key_1', + 1, + 1, + 140, + 'rep', + 'addrr_reward_address_1' +), +( + 8, + 'stake_public_key_2', + 2, + 'voting_key_1', + 1, + 1, + 110, + 'rep', + 'reward_address_2' +), +( + 9, + 'stake_public_key_1', + 2, + 'voting_key_2', + 1, + 1, + 100, + 'rep', + 'addrr_reward_address_1' +), +( + 10, + 'stake_public_key_3', + 2, + 'voting_key_2', + 1, + 1, + 50, + 'rep', + 'reward_address_3' +), +( + 11, + 'stake_public_key_4', + 2, + 'voting_key_3', + 1, + 1, + 350, + 'direct', + 'reward_address_4' +), +( + 12, + 'stake_public_key_5', + 2, + 'voting_key_5', + 1, + 1, + 250, + 'direct', + 'reward_address_5' +), -(13, 'stake_public_key_1', 3, 'voting_key_1', 1, 1, 140, 'rep', 'addrr_reward_address_1'), -(14, 'stake_public_key_2', 3, 'voting_key_1', 1, 1, 110, 'rep', 'reward_address_2'), -(15, 'stake_public_key_1', 3, 'voting_key_2', 1, 1, 100, 'rep', 'addrr_reward_address_1'), -(16, 'stake_public_key_3', 3, 'voting_key_2', 1, 1, 50, 'rep', 'reward_address_4'), -(17, 'stake_public_key_4', 3, 'voting_key_3', 1, 1, 350, 'direct', 'reward_address_5'), -(18, 'stake_public_key_5', 3, 'voting_key_5', 1, 1, 250, 'direct', 'reward_address_5'); +( + 13, + 'stake_public_key_1', + 3, + 'voting_key_1', + 1, + 1, + 140, + 'rep', + 'addrr_reward_address_1' +), +( + 14, + 'stake_public_key_2', + 3, + 'voting_key_1', + 1, + 1, + 110, + 'rep', + 'reward_address_2' +), +( + 15, + 'stake_public_key_1', + 3, + 'voting_key_2', + 1, + 1, + 100, + 'rep', + 'addrr_reward_address_1' +), +( + 16, + 'stake_public_key_3', + 3, + 'voting_key_2', + 1, + 1, + 50, + 'rep', + 'reward_address_4' +), +( + 17, + 'stake_public_key_4', + 3, + 'voting_key_3', + 1, + 1, + 350, + 'direct', + 'reward_address_5' +), +( + 18, + 'stake_public_key_5', + 3, + 'voting_key_5', + 1, + 1, + 250, + 'direct', + 'reward_address_5' +); diff --git a/catalyst-gateway/event-db/test_data/05_goal_table.sql b/catalyst-gateway/event-db/test_data/05_goal_table.sql index 943b7b54a24..a240c89dc2d 100644 --- a/catalyst-gateway/event-db/test_data/05_goal_table.sql +++ b/catalyst-gateway/event-db/test_data/05_goal_table.sql @@ -1,5 +1,5 @@ INSERT INTO goal (id, event_id, idx, name) -VALUES +VALUES (1, 1, 1, 'goal 1'), (2, 1, 2, 'goal 2'), (3, 1, 3, 'goal 3'), @@ -18,4 +18,4 @@ VALUES (13, 4, 13, 'goal 13'), (14, 4, 14, 'goal 14'), (15, 4, 15, 'goal 15'), -(16, 4, 16, 'goal 16'); \ No newline at end of file +(16, 4, 16, 'goal 16'); diff --git a/catalyst-gateway/event-db/test_data/06_objective_table.sql b/catalyst-gateway/event-db/test_data/06_objective_table.sql index 5eb0b75e6c2..1e6d7befefc 100644 --- a/catalyst-gateway/event-db/test_data/06_objective_table.sql +++ b/catalyst-gateway/event-db/test_data/06_objective_table.sql @@ -1,27 +1,51 @@ INSERT INTO objective -(row_id, id, event, category, title, description, rewards_currency, rewards_total, proposers_rewards, vote_options, extra) -VALUES -(1, -1, 1, -'catalyst-simple', 'title 1', 'description 1', -'ADA', 100, 100, 1, -'{"url": "objective 1 url", "sponsor": "objective 1 sponsor", "video": "objective 1 video"}' -), -(2, -2, 1, -'catalyst-native', 'title 2', 'description 2', -NULL, NULL, NULL, NULL, -NULL +( + row_id, + id, + event, + category, + title, + description, + rewards_currency, + rewards_total, + proposers_rewards, + vote_options, + extra +) +VALUES +( + 1, + 1, 1, + 'catalyst-simple', 'title 1', 'description 1', + 'ADA', 100, 100, 1, + '{ + "url": "objective 1 url", + "sponsor": "objective 1 sponsor", + "video": "objective 1 video" + }' ), -(3, -3, 4, -'catalyst-simple', 'title 3', 'description 3', -'ADA', 100, 100, 1, -'{"url": "objective 3 url", "sponsor": "objective 3 sponsor", "video": "objective 3 video"}' -), -(4, -4, 4, -'catalyst-native', 'title 4', 'description 4', -NULL, NULL, NULL, NULL, -NULL +( + 2, + 2, 1, + 'catalyst-native', 'title 2', 'description 2', + NULL, NULL, NULL, NULL, + NULL +), +( + 3, + 3, 4, + 'catalyst-simple', 'title 3', 'description 3', + 'ADA', 100, 100, 1, + '{ + "url": "objective 3 url", + "sponsor": "objective 3 sponsor", + "video": "objective 3 video" + }' +), +( + 4, + 4, 4, + 'catalyst-native', 'title 4', 'description 4', + NULL, NULL, NULL, NULL, + NULL ); diff --git a/catalyst-gateway/event-db/test_data/07_voteplan_table.sql b/catalyst-gateway/event-db/test_data/07_voteplan_table.sql index a191e2eba3b..845821227c6 100644 --- a/catalyst-gateway/event-db/test_data/07_voteplan_table.sql +++ b/catalyst-gateway/event-db/test_data/07_voteplan_table.sql @@ -6,4 +6,4 @@ VALUES (3, 2, '1', 'public', NULL, NULL), (4, 2, '2', 'public', NULL, NULL), (5, 3, '1', 'public', 'direct', 'voting token 3'), -(6, 4, '2', 'public', NULL, NULL); \ No newline at end of file +(6, 4, '2', 'public', NULL, NULL); diff --git a/catalyst-gateway/event-db/test_data/08_proposal_table.sql b/catalyst-gateway/event-db/test_data/08_proposal_table.sql index 39bb162eeb4..e989cd127fe 100644 --- a/catalyst-gateway/event-db/test_data/08_proposal_table.sql +++ b/catalyst-gateway/event-db/test_data/08_proposal_table.sql @@ -1,129 +1,153 @@ INSERT INTO - proposal ( - row_id, - id, - objective, - title, - summary, - category, - public_key, - funds, - url, - files_url, - impact_score, - extra, - proposer_name, - proposer_contact, - proposer_url, - proposer_relevant_experience, - bb_proposal_id - ) +proposal ( + row_id, + id, + objective, + title, + summary, + category, + public_key, + funds, + url, + files_url, + impact_score, + extra, + proposer_name, + proposer_contact, + proposer_url, + proposer_relevant_experience, + bb_proposal_id +) VALUES ( - 1, - 10, - 1, - 'title 1', - 'summary 1', - 'category 1', - 'b7a3c12dc0c8c748ab07525b701122b88bd78f600c76342d27f25e5f92444cde', - 100, - 'url.xyz', - 'files.xyz', - 555, - '{"brief": "Brief explanation of a proposal", "importance": "The importance of the proposal", "goal": "The goal of the proposal is addressed to meet"}', - 'alice', - 'alice@io', - 'alice.prop.xyz', - 'alice is an attorney', - '70726f706f73616c' - ), ( - 2, - 20, - 1, - 'title 2', - 'summary 2', - 'category 2', - 'b7a3c12dc0c8c748ab07525b701122b88bd78f600c76342d27f25e5f92444cde', - 100, - 'url.xyz', - 'files.xyz', - 555, - '{"brief": "Brief explanation of a proposal", "importance": "The importance of the proposal", "goal": "The goal of the proposal is addressed to meet"}', - 'bob', - 'bob@io', - 'bob.prop.xyz', - 'bob is an accountant', - '70726f706f73616c' - ), ( - 3, - 30, - 1, - 'title 3', - 'summary 3', - 'category 3', - 'b7a3c12dc0c8c748ab07525b701122b88bd78f600c76342d27f25e5f92444cde', - 100, - 'url.xyz', - 'files.xyz', - 555, - '{"brief": "Brief explanation of a proposal", "importance": "The importance of the proposal", "goal": "The goal of the proposal is addressed to meet"}', - 'bob', - 'bob@io', - 'bob.prop.xyz', - 'bob is an accountant', - '70726f706f73616c' - ), ( - 4, - 10, - 2, - 'title 1', - 'summary 1', - 'category 1', - 'b7a3c12dc0c8c748ab07525b701122b88bd78f600c76342d27f25e5f92444cde', - 100, - 'url.xyz', - 'files.xyz', - 555, - '{"brief": "Brief explanation of a proposal", "importance": "The importance of the proposal", "goal": "The goal of the proposal is addressed to meet"}', - 'alice', - 'alice@io', - 'alice.prop.xyz', - 'alice is an attorney', - '70726f706f73616c' - ), ( - 5, - 20, - 2, - 'title 2', - 'summary 2', - 'category 2', - 'b7a3c12dc0c8c748ab07525b701122b88bd78f600c76342d27f25e5f92444cde', - 100, - 'url.xyz', - 'files.xyz', - 555, - '{"brief": "Brief explanation of a proposal", "importance": "The importance of the proposal", "goal": "The goal of the proposal is addressed to meet"}', - 'bob', - 'bob@io', - 'bob.prop.xyz', - 'bob is an accountant', - '70726f706f73616c' - ), ( - 6, - 30, - 2, - 'title 3', - 'summary 3', - 'category 3', - 'b7a3c12dc0c8c748ab07525b701122b88bd78f600c76342d27f25e5f92444cde', - 100, - 'url.xyz', - 'files.xyz', - 555, - '{"brief": "Brief explanation of a proposal", "importance": "The importance of the proposal", "goal": "The goal of the proposal is addressed to meet"}', - 'bob', - 'bob@io', - 'bob.prop.xyz', - 'bob is an accountant', - '70726f706f73616c' - ); \ No newline at end of file + 1, + 10, + 1, + 'title 1', + 'summary 1', + 'category 1', + 'b7a3c12dc0c8c748ab07525b701122b88bd78f600c76342d27f25e5f92444cde', + 100, + 'url.xyz', + 'files.xyz', + 555, + '{ + "brief": "Brief explanation of a proposal", + "importance": "The importance of the proposal", + "goal": "The goal of the proposal is addressed to meet" + }', + 'alice', + 'alice@io', + 'alice.prop.xyz', + 'alice is an attorney', + '70726f706f73616c' +), ( + 2, + 20, + 1, + 'title 2', + 'summary 2', + 'category 2', + 'b7a3c12dc0c8c748ab07525b701122b88bd78f600c76342d27f25e5f92444cde', + 100, + 'url.xyz', + 'files.xyz', + 555, + '{ + "brief": "Brief explanation of a proposal", + "importance": "The importance of the proposal", + "goal": "The goal of the proposal is addressed to meet" + }', + 'bob', + 'bob@io', + 'bob.prop.xyz', + 'bob is an accountant', + '70726f706f73616c' +), ( + 3, + 30, + 1, + 'title 3', + 'summary 3', + 'category 3', + 'b7a3c12dc0c8c748ab07525b701122b88bd78f600c76342d27f25e5f92444cde', + 100, + 'url.xyz', + 'files.xyz', + 555, + '{ + "brief": "Brief explanation of a proposal", + "importance": "The importance of the proposal", + "goal": "The goal of the proposal is addressed to meet" + }', + 'bob', + 'bob@io', + 'bob.prop.xyz', + 'bob is an accountant', + '70726f706f73616c' +), ( + 4, + 10, + 2, + 'title 1', + 'summary 1', + 'category 1', + 'b7a3c12dc0c8c748ab07525b701122b88bd78f600c76342d27f25e5f92444cde', + 100, + 'url.xyz', + 'files.xyz', + 555, + '{ + "brief": "Brief explanation of a proposal", + "importance": "The importance of the proposal", + "goal": "The goal of the proposal is addressed to meet" + }', + 'alice', + 'alice@io', + 'alice.prop.xyz', + 'alice is an attorney', + '70726f706f73616c' +), ( + 5, + 20, + 2, + 'title 2', + 'summary 2', + 'category 2', + 'b7a3c12dc0c8c748ab07525b701122b88bd78f600c76342d27f25e5f92444cde', + 100, + 'url.xyz', + 'files.xyz', + 555, + '{ + "brief": "Brief explanation of a proposal", + "importance": "The importance of the proposal", + "goal": "The goal of the proposal is addressed to meet" + }', + 'bob', + 'bob@io', + 'bob.prop.xyz', + 'bob is an accountant', + '70726f706f73616c' +), ( + 6, + 30, + 2, + 'title 3', + 'summary 3', + 'category 3', + 'b7a3c12dc0c8c748ab07525b701122b88bd78f600c76342d27f25e5f92444cde', + 100, + 'url.xyz', + 'files.xyz', + 555, + '{ + "brief": "Brief explanation of a proposal", + "importance": "The importance of the proposal", + "goal": "The goal of the proposal is addressed to meet" + }', + 'bob', + 'bob@io', + 'bob.prop.xyz', + 'bob is an accountant', + '70726f706f73616c' +); diff --git a/catalyst-gateway/event-db/test_data/09_proposal_review_table.sql b/catalyst-gateway/event-db/test_data/09_proposal_review_table.sql index 461c51683d9..1b18291a24e 100644 --- a/catalyst-gateway/event-db/test_data/09_proposal_review_table.sql +++ b/catalyst-gateway/event-db/test_data/09_proposal_review_table.sql @@ -1,19 +1,19 @@ INSERT INTO - proposal_review ( - row_id, - proposal_id, - assessor - ) +proposal_review ( + row_id, + proposal_id, + assessor +) VALUES ( - 1, - 1, - 'assessor 1' - ), ( - 2, - 1, - 'assessor 2' - ), ( - 3, - 1, - 'assessor 3' - ); \ No newline at end of file + 1, + 1, + 'assessor 1' +), ( + 2, + 1, + 'assessor 2' +), ( + 3, + 1, + 'assessor 3' +); diff --git a/catalyst-gateway/event-db/test_data/10_review_rating_table.sql b/catalyst-gateway/event-db/test_data/10_review_rating_table.sql index cd9a048a596..954c0b41e88 100644 --- a/catalyst-gateway/event-db/test_data/10_review_rating_table.sql +++ b/catalyst-gateway/event-db/test_data/10_review_rating_table.sql @@ -1,27 +1,27 @@ INSERT INTO - review_rating ( - row_id, - review_id, - metric, - rating, - note - ) +review_rating ( + row_id, + review_id, + metric, + rating, + note +) VALUES ( - 1, - 1, - 1, - 10, - 'note 1' - ), ( - 2, - 1, - 2, - 15, - 'note 2' - ), ( - 3, - 1, - 5, - 20, - 'note 3' - ); \ No newline at end of file + 1, + 1, + 1, + 10, + 'note 1' +), ( + 2, + 1, + 2, + 15, + 'note 2' +), ( + 3, + 1, + 5, + 20, + 'note 3' +); diff --git a/catalyst-gateway/event-db/test_data/11_objective_review_metric_table.sql b/catalyst-gateway/event-db/test_data/11_objective_review_metric_table.sql index 3cf6b9d2017..528b3cbae50 100644 --- a/catalyst-gateway/event-db/test_data/11_objective_review_metric_table.sql +++ b/catalyst-gateway/event-db/test_data/11_objective_review_metric_table.sql @@ -1,27 +1,27 @@ INSERT INTO - objective_review_metric ( - row_id, - objective, - metric, - note, - review_group - ) +objective_review_metric ( + row_id, + objective, + metric, + note, + review_group +) VALUES ( - 1, - 1, - 1, - NULL, - 'review_group 1' - ), ( - 2, - 1, - 2, - TRUE, - 'review_group 2' - ), ( - 3, - 1, - 5, - FALSE, - NULL - ); \ No newline at end of file + 1, + 1, + 1, + NULL, + 'review_group 1' +), ( + 2, + 1, + 2, + TRUE, + 'review_group 2' +), ( + 3, + 1, + 5, + FALSE, + NULL +);