forked from TevaLabs/Xelma-Backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.ts
More file actions
35 lines (32 loc) · 1.69 KB
/
Copy pathschema.ts
File metadata and controls
35 lines (32 loc) · 1.69 KB
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
import { pgTable, text, integer, doublePrecision, timestamp, serial } from 'drizzle-orm/pg-core';
export const hackathonUsers = pgTable('hackathon_users', {
address: text('address').primaryKey(),
balance: integer('balance').default(1000).notNull(),
pendingWinnings: integer('pending_winnings').default(0).notNull(),
totalWins: integer('total_wins').default(3).notNull(),
totalLosses: integer('total_losses').default(1).notNull(),
currentStreak: integer('current_streak').default(3).notNull(),
xp: integer('xp').default(410).notNull(),
rankTitle: text('rank_title').default('Rookie').notNull(),
});
export const hackathonRounds = pgTable('hackathon_rounds', {
id: text('id').primaryKey(),
asset: text('asset').notNull(),
mode: text('mode').$type<'updown' | 'precision'>().notNull(),
status: text('status').$type<'live' | 'new'>().notNull(),
startPrice: doublePrecision('start_price').notNull(),
poolUp: doublePrecision('pool_up').default(0).notNull(),
poolDown: doublePrecision('pool_down').default(0).notNull(),
totalPool: doublePrecision('total_pool').default(0).notNull(),
predictionCount: integer('prediction_count').default(0).notNull(),
closesAt: text('closes_at').notNull(),
});
export const hackathonBets = pgTable('hackathon_bets', {
id: serial('id').primaryKey(),
roundId: text('round_id').references(() => hackathonRounds.id, { onDelete: 'cascade' }).notNull(),
address: text('address').references(() => hackathonUsers.address, { onDelete: 'cascade' }).notNull(),
amount: doublePrecision('amount').notNull(),
side: text('side').$type<'UP' | 'DOWN'>(),
predictedPrice: doublePrecision('predicted_price'),
createdAt: timestamp('created_at').defaultNow().notNull(),
});