1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
table! {
    api_tokens (token) {
        token -> Binary,
        creation_time -> BigInt,
        expire_time -> BigInt,
    }
}

table! {
    challenges (internal_id) {
        internal_id -> Integer,
        id -> Integer,
        challenge_type -> Text,
        title -> Text,
        description -> Text,
        rewards_total -> BigInt,
        proposers_rewards -> BigInt,
        fund_id -> Integer,
        challenge_url -> Text,
        highlights -> Nullable<Text>,
    }
}

table! {
    community_advisors_reviews (id) {
        id -> Integer,
        proposal_id -> Integer,
        assessor -> Text,
        impact_alignment_rating_given -> Integer,
        impact_alignment_note -> Text,
        feasibility_rating_given -> Integer,
        feasibility_note -> Text,
        auditability_rating_given -> Integer,
        auditability_note -> Text,
        ranking -> Integer,
    }
}

table! {
    contributions (stake_public_key, voting_key, voting_group, snapshot_tag) {
        stake_public_key -> Text,
        reward_address -> Text,
        value -> BigInt,
        voting_key -> Text,
        voting_group -> Text,
        snapshot_tag -> Text,
    }
}

table! {
    funds (id) {
        id -> Integer,
        fund_name -> Text,
        fund_goal -> Text,
        registration_snapshot_time -> BigInt,
        next_registration_snapshot_time -> BigInt,
        voting_power_threshold -> BigInt,
        fund_start_time -> BigInt,
        fund_end_time -> BigInt,
        next_fund_start_time -> BigInt,
        insight_sharing_start -> BigInt,
        proposal_submission_start -> BigInt,
        refine_proposals_start -> BigInt,
        finalize_proposals_start -> BigInt,
        proposal_assessment_start -> BigInt,
        assessment_qa_start -> BigInt,
        snapshot_start -> BigInt,
        voting_start -> BigInt,
        voting_end -> BigInt,
        tallying_end -> BigInt,
        results_url -> Text,
        survey_url -> Text,
    }
}

table! {
    goals (id) {
        id -> Integer,
        goal_name -> Text,
        fund_id -> Integer,
    }
}

table! {
    groups (fund_id, token_identifier) {
        fund_id -> Integer,
        token_identifier -> Text,
        group_id -> Text,
    }
}

table! {
    proposal_community_choice_challenge (proposal_id) {
        proposal_id -> Text,
        proposal_brief -> Nullable<Text>,
        proposal_importance -> Nullable<Text>,
        proposal_goal -> Nullable<Text>,
        proposal_metrics -> Nullable<Text>,
    }
}

table! {
    proposal_simple_challenge (proposal_id) {
        proposal_id -> Text,
        proposal_solution -> Nullable<Text>,
    }
}

table! {
    proposals (id) {
        id -> Integer,
        proposal_id -> Text,
        proposal_category -> Text,
        proposal_title -> Text,
        proposal_summary -> Text,
        proposal_public_key -> Text,
        proposal_funds -> BigInt,
        proposal_url -> Text,
        proposal_files_url -> Text,
        proposal_impact_score -> BigInt,
        proposer_name -> Text,
        proposer_contact -> Text,
        proposer_url -> Text,
        proposer_relevant_experience -> Text,
        chain_proposal_id -> Binary,
        chain_vote_options -> Array<Text>,
        challenge_id -> Integer,
        extra -> Nullable<Text>,
    }
}

table! {
    proposals_voteplans (id) {
        id -> Integer,
        proposal_id -> Text,
        chain_voteplan_id -> Text,
        chain_proposal_index -> BigInt,
    }
}

table! {
    snapshots (tag) {
        tag -> Text,
        last_updated -> BigInt,
    }
}

table! {
    voteplans (id) {
        id -> Integer,
        chain_voteplan_id -> Text,
        chain_vote_start_time -> BigInt,
        chain_vote_end_time -> BigInt,
        chain_committee_end_time -> BigInt,
        chain_voteplan_payload -> Text,
        chain_vote_encryption_key -> Text,
        fund_id -> Integer,
        token_identifier -> Text,
    }
}

table! {
    voters (voting_key, voting_group, snapshot_tag) {
        voting_key -> Text,
        voting_power -> BigInt,
        voting_group -> Text,
        snapshot_tag -> Text,
    }
}

table! {
    votes (fragment_id) {
        fragment_id -> Text,
        caster -> Text,
        proposal -> Integer,
        voteplan_id -> Text,
        time -> Float,
        choice -> Nullable<SmallInt>,
        raw_fragment -> Text,
    }
}

joinable!(contributions -> snapshots (snapshot_tag));
joinable!(goals -> funds (fund_id));
joinable!(voters -> snapshots (snapshot_tag));

allow_tables_to_appear_in_same_query!(
    api_tokens,
    challenges,
    community_advisors_reviews,
    contributions,
    funds,
    goals,
    groups,
    proposal_community_choice_challenge,
    proposal_simple_challenge,
    proposals,
    proposals_voteplans,
    snapshots,
    voteplans,
    voters,
    votes,
);