Skip to content

Commit 640b7e5

Browse files
authored
fix: add new columns in schema.sql (#469)
* fix: add new columns in schema.sq * test: fix test * fix: update proposals table sql schema to match with production db * fix: revert changes, and add notes explaning discrepancies with prod db schema * docs: add columns name in notes
1 parent 1738133 commit 640b7e5

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

test/e2e/api.test.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import fetch from 'node-fetch';
2+
import db from '../../src/helpers/mysql';
23
import proposalInput from '../fixtures/ingestor-payload/proposal.json';
3-
import { spacesSqlFixtures } from '../fixtures/space';
44
import proposalsFixtures from '../fixtures/proposal';
5-
import db from '../../src/helpers/mysql';
5+
import { spacesSqlFixtures } from '../fixtures/space';
66

77
const HOST = `http://localhost:${process.env.PORT || 3003}`;
88
const SPACE_PREFIX = 'e2e-';
@@ -71,7 +71,8 @@ describe('POST /flag', () => {
7171
plugins: JSON.stringify(proposal.plugins),
7272
choices: JSON.stringify(proposal.choices),
7373
scores: JSON.stringify(proposal.scores),
74-
scores_by_strategy: JSON.stringify(proposal.scores_by_strategy)
74+
scores_by_strategy: JSON.stringify(proposal.scores_by_strategy),
75+
vp_value_by_strategy: JSON.stringify(proposal.vp_value_by_strategy || [])
7576
}))
7677
.map(async proposal => {
7778
db.queryAsync('INSERT INTO snapshot_sequencer_test.proposals SET ?', proposal);

test/schema.sql

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ CREATE TABLE spaces (
2828
INDEX updated (updated)
2929
);
3030

31+
-- Note: The `proposals` table schema might have some discrepancies
32+
-- compared to the production database. This is due to legacy reasons
33+
-- and the challenges associated with updating the schema because of its size.
34+
-- `id` and `ipfs` columns should not have any default values.
3135
CREATE TABLE proposals (
3236
id VARCHAR(66) NOT NULL,
3337
ipfs VARCHAR(64) NOT NULL,
@@ -36,8 +40,8 @@ CREATE TABLE proposals (
3640
updated INT(11) DEFAULT NULL,
3741
space VARCHAR(64) NOT NULL,
3842
network VARCHAR(12) NOT NULL,
39-
symbol VARCHAR(16) NOT NULL,
40-
type VARCHAR(24) NOT NULL,
43+
symbol VARCHAR(16) NOT NULL DEFAULT '',
44+
type VARCHAR(24) NOT NULL DEFAULT '',
4145
strategies JSON NOT NULL,
4246
validation JSON NOT NULL,
4347
plugins JSON NOT NULL,
@@ -49,17 +53,20 @@ CREATE TABLE proposals (
4953
start INT(11) NOT NULL,
5054
end INT(11) NOT NULL,
5155
quorum DECIMAL(64,30) NOT NULL,
52-
quorum_type VARCHAR(24) NOT NULL DEFAULT '',
56+
quorum_type VARCHAR(24) DEFAULT '',
5357
privacy VARCHAR(24) NOT NULL,
5458
snapshot INT(24) NOT NULL,
5559
app VARCHAR(24) NOT NULL,
5660
scores JSON NOT NULL,
5761
scores_by_strategy JSON NOT NULL,
58-
scores_state VARCHAR(24) NOT NULL,
62+
scores_state VARCHAR(24) NOT NULL DEFAULT '',
5963
scores_total DECIMAL(64,30) NOT NULL,
6064
scores_updated INT(11) NOT NULL,
65+
scores_total_value DECIMAL(64,30) NOT NULL DEFAULT '0.000000000000000000000000000000',
66+
vp_value_by_strategy json NOT NULL,
6167
votes INT(12) NOT NULL,
6268
flagged INT NOT NULL DEFAULT 0,
69+
cb INT NOT NULL DEFAULT 0,
6370
PRIMARY KEY (id),
6471
INDEX ipfs (ipfs),
6572
INDEX author (author),
@@ -73,7 +80,8 @@ CREATE TABLE proposals (
7380
INDEX scores_state (scores_state),
7481
INDEX scores_updated (scores_updated),
7582
INDEX votes (votes),
76-
INDEX flagged (flagged)
83+
INDEX flagged (flagged),
84+
INDEX cb (cb)
7785
);
7886

7987
CREATE TABLE votes (

0 commit comments

Comments
 (0)