Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
affanv14 committed Jul 18, 2024
1 parent 8f76dea commit 76333e7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as Knex from 'knex';

export async function up(knex: Knex): Promise<void> {
return knex.schema.createTable('leaderboard_pnl', (table) => {
table.string('address').notNullable();
table.string('address').notNullable().references('address').inTable('wallets');
table.enum(
'timeSpan',
[
Expand Down
15 changes: 14 additions & 1 deletion indexer/packages/postgres/src/models/leaderboard-pnl-model.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import path from 'path';

import { Model } from 'objection';

import { NumericPattern } from '../lib/validators';
import UpsertQueryBuilder from '../query-builders/upsert';
import BaseModel from './base-model';
Expand All @@ -12,7 +16,16 @@ export default class LeaderboardPnlModel extends BaseModel {
return ['address', 'timeSpan'];
}

static relationMappings = {};
static relationMappings = {
wallets: {
relation: Model.BelongsToOneRelation,
modelClass: path.join(__dirname, 'wallet-model'),
join: {
from: 'leaderboard_pnl.address',
to: 'wallets.address',
},
},
};

static get jsonSchema() {
return {
Expand Down

0 comments on commit 76333e7

Please sign in to comment.