diff --git a/Dockerfile b/Dockerfile
index 2a014e3..703d96b 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,10 +1,8 @@
# syntax = docker/dockerfile:1
-
ARG NODE_VERSION=20
FROM node:${NODE_VERSION}-slim AS base-node
WORKDIR /app
ENV NODE_ENV="production"
-
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y \
build-essential \
@@ -18,7 +16,6 @@ RUN apt-get update -qq && \
&& rm -rf /var/lib/apt/lists/*
FROM base-node AS build-main
-
# Copy package files
COPY website/package.json website/package-lock.json* ./
@@ -32,58 +29,31 @@ COPY website/. .
RUN mkdir -p .svelte-kit
# Generate SvelteKit types and build
+
RUN npm run build
FROM base-node AS build-websocket
WORKDIR /websocket
-
RUN curl -fsSL https://bun.sh/install | bash
ENV PATH="/root/.bun/bin:${PATH}"
-
COPY website/websocket/package.json website/websocket/bun.lock* ./
COPY website/websocket/tsconfig.json ./
-
RUN bun install
-
COPY website/websocket/src ./src/
-
RUN bun build src/main.ts --outdir dist --target bun
FROM base-node AS production-main
-
COPY --from=build-main --chown=node:node /app/build ./build
COPY --from=build-main --chown=node:node /app/node_modules ./node_modules
COPY --from=build-main --chown=node:node /app/package.json ./package.json
-
-RUN npm install -g pm2
-
-RUN echo 'module.exports = {\
- apps: [{\
- name: "rugplay-app",\
- script: "./build/index.js",\
- instances: "max",\
- exec_mode: "cluster",\
- env: {\
- NODE_ENV: "production",\
- PORT: 3000,\
- BODY_SIZE_LIMIT: "1.1M"\
- }\
- }]\
-};' > ecosystem.config.cjs
-
USER node
EXPOSE 3000
+CMD ["node", "build"]
-CMD ["pm2-runtime", "start", "ecosystem.config.cjs"]
-
-FROM base-node AS production-websocket
+FROM oven/bun:1 AS production-websocket
WORKDIR /websocket
-
-RUN curl -fsSL https://bun.sh/install | bash
-ENV PATH="/root/.bun/bin:${PATH}"
-
-COPY --from=build-websocket /websocket/dist ./dist
-COPY --from=build-websocket /websocket/package.json ./package.json
-
+COPY --from=build-websocket --chown=bun:bun /websocket/dist ./dist
+COPY --from=build-websocket --chown=bun:bun /websocket/package.json ./package.json
+USER bun
EXPOSE 8080
CMD ["bun", "run", "dist/main.js"]
\ No newline at end of file
diff --git a/docker-compose.yml b/docker-compose.yml
index dbb5493..d577469 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -5,14 +5,16 @@ services:
target: production-main
dockerfile: Dockerfile
ports:
- - "3002:3000"
+ - "5900-5907:3000"
env_file:
- website/.env
depends_on:
- websocket
- - redis
- - postgres
restart: unless-stopped
+ networks:
+ - shared_backend
+ deploy:
+ replicas: 8
websocket:
build:
@@ -20,33 +22,13 @@ services:
target: production-websocket
dockerfile: Dockerfile
ports:
- - "8081:8080"
+ - "8082:8080"
env_file:
- website/.env
- depends_on:
- - redis
restart: unless-stopped
+ networks:
+ - shared_backend
- redis:
- image: redis:8-alpine
- volumes:
- - rugplay_redisdata:/data
- command: "redis-server --save 60 1"
- restart: unless-stopped
-
- postgres:
- image: pgvector/pgvector:pg16
- container_name: rugplay-postgres
- environment:
- POSTGRES_USER: ${POSTGRES_USER}
- POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
- POSTGRES_DB: ${POSTGRES_DB:-rugplay}
- ports:
- - "5432:5432"
- volumes:
- - rugplay_pgdata:/var/lib/postgresql/data
- restart: unless-stopped
-
-volumes:
- rugplay_pgdata:
- rugplay_redisdata:
+networks:
+ shared_backend:
+ external: true
\ No newline at end of file
diff --git a/website/drizzle/0003_complete_runaways.sql b/website/drizzle/0003_complete_runaways.sql
new file mode 100644
index 0000000..a7b2e52
--- /dev/null
+++ b/website/drizzle/0003_complete_runaways.sql
@@ -0,0 +1,19 @@
+CREATE INDEX IF NOT EXISTS "coin_symbol_idx" ON "coin" USING btree ("symbol");--> statement-breakpoint
+CREATE INDEX IF NOT EXISTS "coin_creator_id_idx" ON "coin" USING btree ("creator_id");--> statement-breakpoint
+CREATE INDEX IF NOT EXISTS "coin_is_listed_idx" ON "coin" USING btree ("is_listed");--> statement-breakpoint
+CREATE INDEX IF NOT EXISTS "coin_market_cap_idx" ON "coin" USING btree ("market_cap");--> statement-breakpoint
+CREATE INDEX IF NOT EXISTS "coin_current_price_idx" ON "coin" USING btree ("current_price");--> statement-breakpoint
+CREATE INDEX IF NOT EXISTS "coin_change24h_idx" ON "coin" USING btree ("change_24h");--> statement-breakpoint
+CREATE INDEX IF NOT EXISTS "coin_volume24h_idx" ON "coin" USING btree ("volume_24h");--> statement-breakpoint
+CREATE INDEX IF NOT EXISTS "coin_created_at_idx" ON "coin" USING btree ("created_at");--> statement-breakpoint
+CREATE INDEX IF NOT EXISTS "transaction_user_id_idx" ON "transaction" USING btree ("user_id");--> statement-breakpoint
+CREATE INDEX IF NOT EXISTS "transaction_coin_id_idx" ON "transaction" USING btree ("coin_id");--> statement-breakpoint
+CREATE INDEX IF NOT EXISTS "transaction_type_idx" ON "transaction" USING btree ("type");--> statement-breakpoint
+CREATE INDEX IF NOT EXISTS "transaction_timestamp_idx" ON "transaction" USING btree ("timestamp");--> statement-breakpoint
+CREATE INDEX IF NOT EXISTS "transaction_user_coin_idx" ON "transaction" USING btree ("user_id","coin_id");--> statement-breakpoint
+CREATE INDEX IF NOT EXISTS "transaction_coin_type_idx" ON "transaction" USING btree ("coin_id","type");--> statement-breakpoint
+CREATE INDEX IF NOT EXISTS "user_username_idx" ON "user" USING btree ("username");--> statement-breakpoint
+CREATE INDEX IF NOT EXISTS "user_is_banned_idx" ON "user" USING btree ("is_banned");--> statement-breakpoint
+CREATE INDEX IF NOT EXISTS "user_is_admin_idx" ON "user" USING btree ("is_admin");--> statement-breakpoint
+CREATE INDEX IF NOT EXISTS "user_created_at_idx" ON "user" USING btree ("created_at");--> statement-breakpoint
+CREATE INDEX IF NOT EXISTS "user_updated_at_idx" ON "user" USING btree ("updated_at");
\ No newline at end of file
diff --git a/website/drizzle/meta/0003_snapshot.json b/website/drizzle/meta/0003_snapshot.json
new file mode 100644
index 0000000..7abf363
--- /dev/null
+++ b/website/drizzle/meta/0003_snapshot.json
@@ -0,0 +1,2027 @@
+{
+ "id": "496c23a1-1fd7-4116-b72d-5b56db3e7059",
+ "prevId": "223d9abc-f0d3-4c71-9cda-8a069fc13205",
+ "version": "7",
+ "dialect": "postgresql",
+ "tables": {
+ "public.account": {
+ "name": "account",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "account_id": {
+ "name": "account_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_id": {
+ "name": "provider_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "access_token": {
+ "name": "access_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refresh_token": {
+ "name": "refresh_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "id_token": {
+ "name": "id_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "access_token_expires_at": {
+ "name": "access_token_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refresh_token_expires_at": {
+ "name": "refresh_token_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "password": {
+ "name": "password",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "account_user_id_user_id_fk": {
+ "name": "account_user_id_user_id_fk",
+ "tableFrom": "account",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {}
+ },
+ "public.account_deletion_request": {
+ "name": "account_deletion_request",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "requested_at": {
+ "name": "requested_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "scheduled_deletion_at": {
+ "name": "scheduled_deletion_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "reason": {
+ "name": "reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_processed": {
+ "name": "is_processed",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ }
+ },
+ "indexes": {
+ "account_deletion_request_user_id_idx": {
+ "name": "account_deletion_request_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "account_deletion_request_scheduled_deletion_idx": {
+ "name": "account_deletion_request_scheduled_deletion_idx",
+ "columns": [
+ {
+ "expression": "scheduled_deletion_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "account_deletion_request_open_idx": {
+ "name": "account_deletion_request_open_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "is_processed = false",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "account_deletion_request_user_id_user_id_fk": {
+ "name": "account_deletion_request_user_id_user_id_fk",
+ "tableFrom": "account_deletion_request",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "account_deletion_request_user_id_unique": {
+ "name": "account_deletion_request_user_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "user_id"
+ ]
+ }
+ }
+ },
+ "public.coin": {
+ "name": "coin",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "symbol": {
+ "name": "symbol",
+ "type": "varchar(10)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "icon": {
+ "name": "icon",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "creator_id": {
+ "name": "creator_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "initial_supply": {
+ "name": "initial_supply",
+ "type": "numeric(30, 8)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "circulating_supply": {
+ "name": "circulating_supply",
+ "type": "numeric(30, 8)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "current_price": {
+ "name": "current_price",
+ "type": "numeric(20, 8)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "market_cap": {
+ "name": "market_cap",
+ "type": "numeric(30, 2)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "volume_24h": {
+ "name": "volume_24h",
+ "type": "numeric(30, 2)",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'0.00'"
+ },
+ "change_24h": {
+ "name": "change_24h",
+ "type": "numeric(30, 4)",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'0.0000'"
+ },
+ "pool_coin_amount": {
+ "name": "pool_coin_amount",
+ "type": "numeric(30, 8)",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'0.00000000'"
+ },
+ "pool_base_currency_amount": {
+ "name": "pool_base_currency_amount",
+ "type": "numeric(30, 8)",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'0.00000000'"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "is_listed": {
+ "name": "is_listed",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ }
+ },
+ "indexes": {
+ "coin_symbol_idx": {
+ "name": "coin_symbol_idx",
+ "columns": [
+ {
+ "expression": "symbol",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "coin_creator_id_idx": {
+ "name": "coin_creator_id_idx",
+ "columns": [
+ {
+ "expression": "creator_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "coin_is_listed_idx": {
+ "name": "coin_is_listed_idx",
+ "columns": [
+ {
+ "expression": "is_listed",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "coin_market_cap_idx": {
+ "name": "coin_market_cap_idx",
+ "columns": [
+ {
+ "expression": "market_cap",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "coin_current_price_idx": {
+ "name": "coin_current_price_idx",
+ "columns": [
+ {
+ "expression": "current_price",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "coin_change24h_idx": {
+ "name": "coin_change24h_idx",
+ "columns": [
+ {
+ "expression": "change_24h",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "coin_volume24h_idx": {
+ "name": "coin_volume24h_idx",
+ "columns": [
+ {
+ "expression": "volume_24h",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "coin_created_at_idx": {
+ "name": "coin_created_at_idx",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "coin_creator_id_user_id_fk": {
+ "name": "coin_creator_id_user_id_fk",
+ "tableFrom": "coin",
+ "tableTo": "user",
+ "columnsFrom": [
+ "creator_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "coin_symbol_unique": {
+ "name": "coin_symbol_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "symbol"
+ ]
+ }
+ }
+ },
+ "public.comment": {
+ "name": "comment",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "coin_id": {
+ "name": "coin_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "content": {
+ "name": "content",
+ "type": "varchar(500)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "likes_count": {
+ "name": "likes_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "is_deleted": {
+ "name": "is_deleted",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ }
+ },
+ "indexes": {
+ "comment_user_id_idx": {
+ "name": "comment_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "comment_coin_id_idx": {
+ "name": "comment_coin_id_idx",
+ "columns": [
+ {
+ "expression": "coin_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "comment_user_id_user_id_fk": {
+ "name": "comment_user_id_user_id_fk",
+ "tableFrom": "comment",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "comment_coin_id_coin_id_fk": {
+ "name": "comment_coin_id_coin_id_fk",
+ "tableFrom": "comment",
+ "tableTo": "coin",
+ "columnsFrom": [
+ "coin_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {}
+ },
+ "public.comment_like": {
+ "name": "comment_like",
+ "schema": "",
+ "columns": {
+ "user_id": {
+ "name": "user_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "comment_id": {
+ "name": "comment_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "comment_like_user_id_user_id_fk": {
+ "name": "comment_like_user_id_user_id_fk",
+ "tableFrom": "comment_like",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "comment_like_comment_id_comment_id_fk": {
+ "name": "comment_like_comment_id_comment_id_fk",
+ "tableFrom": "comment_like",
+ "tableTo": "comment",
+ "columnsFrom": [
+ "comment_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "comment_like_user_id_comment_id_pk": {
+ "name": "comment_like_user_id_comment_id_pk",
+ "columns": [
+ "user_id",
+ "comment_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {}
+ },
+ "public.notification": {
+ "name": "notification",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "notification_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "varchar(200)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "message": {
+ "name": "message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "is_read": {
+ "name": "is_read",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "notification_user_id_idx": {
+ "name": "notification_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "notification_type_idx": {
+ "name": "notification_type_idx",
+ "columns": [
+ {
+ "expression": "type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "notification_is_read_idx": {
+ "name": "notification_is_read_idx",
+ "columns": [
+ {
+ "expression": "is_read",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "notification_created_at_idx": {
+ "name": "notification_created_at_idx",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "notification_user_id_user_id_fk": {
+ "name": "notification_user_id_user_id_fk",
+ "tableFrom": "notification",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {}
+ },
+ "public.prediction_bet": {
+ "name": "prediction_bet",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "question_id": {
+ "name": "question_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "side": {
+ "name": "side",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "amount": {
+ "name": "amount",
+ "type": "numeric(20, 8)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "actual_winnings": {
+ "name": "actual_winnings",
+ "type": "numeric(20, 8)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "settled_at": {
+ "name": "settled_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "prediction_bet_user_id_idx": {
+ "name": "prediction_bet_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "prediction_bet_question_id_idx": {
+ "name": "prediction_bet_question_id_idx",
+ "columns": [
+ {
+ "expression": "question_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "prediction_bet_user_question_idx": {
+ "name": "prediction_bet_user_question_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "question_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "prediction_bet_created_at_idx": {
+ "name": "prediction_bet_created_at_idx",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "prediction_bet_user_id_user_id_fk": {
+ "name": "prediction_bet_user_id_user_id_fk",
+ "tableFrom": "prediction_bet",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "prediction_bet_question_id_prediction_question_id_fk": {
+ "name": "prediction_bet_question_id_prediction_question_id_fk",
+ "tableFrom": "prediction_bet",
+ "tableTo": "prediction_question",
+ "columnsFrom": [
+ "question_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {}
+ },
+ "public.prediction_question": {
+ "name": "prediction_question",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "creator_id": {
+ "name": "creator_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "question": {
+ "name": "question",
+ "type": "varchar(200)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "prediction_market_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'ACTIVE'"
+ },
+ "resolution_date": {
+ "name": "resolution_date",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "ai_resolution": {
+ "name": "ai_resolution",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_yes_amount": {
+ "name": "total_yes_amount",
+ "type": "numeric(20, 8)",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'0.00000000'"
+ },
+ "total_no_amount": {
+ "name": "total_no_amount",
+ "type": "numeric(20, 8)",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'0.00000000'"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "resolved_at": {
+ "name": "resolved_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "requires_web_search": {
+ "name": "requires_web_search",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "validation_reason": {
+ "name": "validation_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "prediction_question_creator_id_idx": {
+ "name": "prediction_question_creator_id_idx",
+ "columns": [
+ {
+ "expression": "creator_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "prediction_question_status_idx": {
+ "name": "prediction_question_status_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "prediction_question_resolution_date_idx": {
+ "name": "prediction_question_resolution_date_idx",
+ "columns": [
+ {
+ "expression": "resolution_date",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "prediction_question_status_resolution_idx": {
+ "name": "prediction_question_status_resolution_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "resolution_date",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "prediction_question_creator_id_user_id_fk": {
+ "name": "prediction_question_creator_id_user_id_fk",
+ "tableFrom": "prediction_question",
+ "tableTo": "user",
+ "columnsFrom": [
+ "creator_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {}
+ },
+ "public.price_history": {
+ "name": "price_history",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "coin_id": {
+ "name": "coin_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "price": {
+ "name": "price",
+ "type": "numeric(20, 8)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "timestamp": {
+ "name": "timestamp",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "price_history_coin_id_coin_id_fk": {
+ "name": "price_history_coin_id_coin_id_fk",
+ "tableFrom": "price_history",
+ "tableTo": "coin",
+ "columnsFrom": [
+ "coin_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {}
+ },
+ "public.promo_code": {
+ "name": "promo_code",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "code": {
+ "name": "code",
+ "type": "varchar(50)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reward_amount": {
+ "name": "reward_amount",
+ "type": "numeric(20, 8)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "max_uses": {
+ "name": "max_uses",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_active": {
+ "name": "is_active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "promo_code_created_by_user_id_fk": {
+ "name": "promo_code_created_by_user_id_fk",
+ "tableFrom": "promo_code",
+ "tableTo": "user",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "promo_code_code_unique": {
+ "name": "promo_code_code_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "code"
+ ]
+ }
+ }
+ },
+ "public.promo_code_redemption": {
+ "name": "promo_code_redemption",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "promo_code_id": {
+ "name": "promo_code_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "reward_amount": {
+ "name": "reward_amount",
+ "type": "numeric(20, 8)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "redeemed_at": {
+ "name": "redeemed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "promo_code_redemption_user_id_user_id_fk": {
+ "name": "promo_code_redemption_user_id_user_id_fk",
+ "tableFrom": "promo_code_redemption",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "promo_code_redemption_promo_code_id_promo_code_id_fk": {
+ "name": "promo_code_redemption_promo_code_id_promo_code_id_fk",
+ "tableFrom": "promo_code_redemption",
+ "tableTo": "promo_code",
+ "columnsFrom": [
+ "promo_code_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "promo_code_redemption_user_id_promo_code_id_unique": {
+ "name": "promo_code_redemption_user_id_promo_code_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "user_id",
+ "promo_code_id"
+ ]
+ }
+ }
+ },
+ "public.session": {
+ "name": "session",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "ip_address": {
+ "name": "ip_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_agent": {
+ "name": "user_agent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "session_user_id_user_id_fk": {
+ "name": "session_user_id_user_id_fk",
+ "tableFrom": "session",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "session_token_unique": {
+ "name": "session_token_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "token"
+ ]
+ }
+ }
+ },
+ "public.transaction": {
+ "name": "transaction",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "coin_id": {
+ "name": "coin_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "transaction_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "quantity": {
+ "name": "quantity",
+ "type": "numeric(30, 8)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "price_per_coin": {
+ "name": "price_per_coin",
+ "type": "numeric(20, 8)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "total_base_currency_amount": {
+ "name": "total_base_currency_amount",
+ "type": "numeric(30, 8)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "timestamp": {
+ "name": "timestamp",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "recipient_user_id": {
+ "name": "recipient_user_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sender_user_id": {
+ "name": "sender_user_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "transaction_user_id_idx": {
+ "name": "transaction_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "transaction_coin_id_idx": {
+ "name": "transaction_coin_id_idx",
+ "columns": [
+ {
+ "expression": "coin_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "transaction_type_idx": {
+ "name": "transaction_type_idx",
+ "columns": [
+ {
+ "expression": "type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "transaction_timestamp_idx": {
+ "name": "transaction_timestamp_idx",
+ "columns": [
+ {
+ "expression": "timestamp",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "transaction_user_coin_idx": {
+ "name": "transaction_user_coin_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "coin_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "transaction_coin_type_idx": {
+ "name": "transaction_coin_type_idx",
+ "columns": [
+ {
+ "expression": "coin_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "transaction_user_id_user_id_fk": {
+ "name": "transaction_user_id_user_id_fk",
+ "tableFrom": "transaction",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "transaction_coin_id_coin_id_fk": {
+ "name": "transaction_coin_id_coin_id_fk",
+ "tableFrom": "transaction",
+ "tableTo": "coin",
+ "columnsFrom": [
+ "coin_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "transaction_recipient_user_id_user_id_fk": {
+ "name": "transaction_recipient_user_id_user_id_fk",
+ "tableFrom": "transaction",
+ "tableTo": "user",
+ "columnsFrom": [
+ "recipient_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "transaction_sender_user_id_user_id_fk": {
+ "name": "transaction_sender_user_id_user_id_fk",
+ "tableFrom": "transaction",
+ "tableTo": "user",
+ "columnsFrom": [
+ "sender_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {}
+ },
+ "public.user": {
+ "name": "user",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email_verified": {
+ "name": "email_verified",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "image": {
+ "name": "image",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "is_admin": {
+ "name": "is_admin",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "is_banned": {
+ "name": "is_banned",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "ban_reason": {
+ "name": "ban_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "base_currency_balance": {
+ "name": "base_currency_balance",
+ "type": "numeric(20, 8)",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'100.00000000'"
+ },
+ "bio": {
+ "name": "bio",
+ "type": "varchar(160)",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'Hello am 48 year old man from somalia. Sorry for my bed england. I selled my wife for internet connection for play “conter stirk”'"
+ },
+ "username": {
+ "name": "username",
+ "type": "varchar(30)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "volume_master": {
+ "name": "volume_master",
+ "type": "numeric(3, 2)",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'0.70'"
+ },
+ "volume_muted": {
+ "name": "volume_muted",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "last_reward_claim": {
+ "name": "last_reward_claim",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_rewards_claimed": {
+ "name": "total_rewards_claimed",
+ "type": "numeric(20, 8)",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'0.00000000'"
+ },
+ "login_streak": {
+ "name": "login_streak",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "prestige_level": {
+ "name": "prestige_level",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 0
+ }
+ },
+ "indexes": {
+ "user_username_idx": {
+ "name": "user_username_idx",
+ "columns": [
+ {
+ "expression": "username",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_is_banned_idx": {
+ "name": "user_is_banned_idx",
+ "columns": [
+ {
+ "expression": "is_banned",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_is_admin_idx": {
+ "name": "user_is_admin_idx",
+ "columns": [
+ {
+ "expression": "is_admin",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_created_at_idx": {
+ "name": "user_created_at_idx",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_updated_at_idx": {
+ "name": "user_updated_at_idx",
+ "columns": [
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_email_unique": {
+ "name": "user_email_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "email"
+ ]
+ },
+ "user_username_unique": {
+ "name": "user_username_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "username"
+ ]
+ }
+ }
+ },
+ "public.user_portfolio": {
+ "name": "user_portfolio",
+ "schema": "",
+ "columns": {
+ "user_id": {
+ "name": "user_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "coin_id": {
+ "name": "coin_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "quantity": {
+ "name": "quantity",
+ "type": "numeric(30, 8)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "user_portfolio_user_id_user_id_fk": {
+ "name": "user_portfolio_user_id_user_id_fk",
+ "tableFrom": "user_portfolio",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_portfolio_coin_id_coin_id_fk": {
+ "name": "user_portfolio_coin_id_coin_id_fk",
+ "tableFrom": "user_portfolio",
+ "tableTo": "coin",
+ "columnsFrom": [
+ "coin_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "user_portfolio_user_id_coin_id_pk": {
+ "name": "user_portfolio_user_id_coin_id_pk",
+ "columns": [
+ "user_id",
+ "coin_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {}
+ },
+ "public.verification": {
+ "name": "verification",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {}
+ }
+ },
+ "enums": {
+ "public.notification_type": {
+ "name": "notification_type",
+ "schema": "public",
+ "values": [
+ "HOPIUM",
+ "SYSTEM",
+ "TRANSFER",
+ "RUG_PULL"
+ ]
+ },
+ "public.prediction_market_status": {
+ "name": "prediction_market_status",
+ "schema": "public",
+ "values": [
+ "ACTIVE",
+ "RESOLVED",
+ "CANCELLED"
+ ]
+ },
+ "public.transaction_type": {
+ "name": "transaction_type",
+ "schema": "public",
+ "values": [
+ "BUY",
+ "SELL",
+ "TRANSFER_IN",
+ "TRANSFER_OUT"
+ ]
+ }
+ },
+ "schemas": {},
+ "_meta": {
+ "columns": {},
+ "schemas": {},
+ "tables": {}
+ }
+}
\ No newline at end of file
diff --git a/website/drizzle/meta/_journal.json b/website/drizzle/meta/_journal.json
index aede010..6f60140 100644
--- a/website/drizzle/meta/_journal.json
+++ b/website/drizzle/meta/_journal.json
@@ -22,6 +22,13 @@
"when": 1749916220202,
"tag": "0002_small_micromacro",
"breakpoints": true
+ },
+ {
+ "idx": 3,
+ "version": "7",
+ "when": 1750707307426,
+ "tag": "0003_complete_runaways",
+ "breakpoints": true
}
]
}
\ No newline at end of file
diff --git a/website/src/hooks.server.ts b/website/src/hooks.server.ts
index abd3d72..8a37675 100644
--- a/website/src/hooks.server.ts
+++ b/website/src/hooks.server.ts
@@ -7,6 +7,7 @@ import { redirect, type Handle } from '@sveltejs/kit';
import { db } from '$lib/server/db';
import { user } from '$lib/server/db/schema';
import { eq } from 'drizzle-orm';
+import { minesCleanupInactiveGames, minesAutoCashout } from '$lib/server/games/mines';
async function initializeScheduler() {
if (building) return;
@@ -49,10 +50,16 @@ async function initializeScheduler() {
processAccountDeletions().catch(console.error);
}, 5 * 60 * 1000);
+ const minesCleanupInterval = setInterval(() => {
+ minesCleanupInactiveGames().catch(console.error);
+ minesAutoCashout().catch(console.error);
+ }, 60 * 1000);
+
// Cleanup on process exit
const cleanup = async () => {
clearInterval(renewInterval);
clearInterval(schedulerInterval);
+ clearInterval(minesCleanupInterval);
const currentValue = await redis.get(lockKey);
if (currentValue === lockValue) {
await redis.del(lockKey);
@@ -172,6 +179,13 @@ export const handle: Handle = async ({ event, resolve }) => {
event.locals.userSession = userData;
+ if (event.url.pathname.startsWith('/api/')) {
+ const response = await svelteKitHandler({ event, resolve, auth });
+ response.headers.set('Cache-Control', 'no-store, no-cache, must-revalidate, private');
+
+ return response;
+ }
+
return svelteKitHandler({ event, resolve, auth });
};
diff --git a/website/src/lib/components/self/TradeModal.svelte b/website/src/lib/components/self/TradeModal.svelte
index 9c323dd..f554103 100644
--- a/website/src/lib/components/self/TradeModal.svelte
+++ b/website/src/lib/components/self/TradeModal.svelte
@@ -212,4 +212,4 @@
-
+
\ No newline at end of file
diff --git a/website/src/lib/components/self/games/Coinflip.svelte b/website/src/lib/components/self/games/Coinflip.svelte
index daa940d..e4aac9a 100644
--- a/website/src/lib/components/self/games/Coinflip.svelte
+++ b/website/src/lib/components/self/games/Coinflip.svelte
@@ -164,6 +164,7 @@
import { formatValue, playSound, showConfetti } from '$lib/utils';
import { volumeSettings } from '$lib/stores/volume-settings';
import { onMount } from 'svelte';
+ import { fetchPortfolioSummary } from '$lib/stores/portfolio-data';
interface CoinflipResult {
won: boolean;
@@ -314,8 +315,18 @@
}
}
- onMount(() => {
+ onMount(async () => {
volumeSettings.load();
+
+ try {
+ const data = await fetchPortfolioSummary();
+ if (data) {
+ balance = data.baseCurrencyBalance;
+ onBalanceUpdate?.(data.baseCurrencyBalance);
+ }
+ } catch (error) {
+ console.error('Failed to fetch balance:', error);
+ }
});
diff --git a/website/src/lib/components/self/games/Dice.svelte b/website/src/lib/components/self/games/Dice.svelte
new file mode 100644
index 0000000..ea4430c
--- /dev/null
+++ b/website/src/lib/components/self/games/Dice.svelte
@@ -0,0 +1,419 @@
+
+
+ Balance {formatValue(balance)} WIN
+ Won {formatValue(lastResult.payout)} on {lastResult.result}
+ LOSS
+ Lost {formatValue(lastResult.amountWagered)} on {lastResult.result}
+
+ Max bet: {MAX_BET_AMOUNT.toLocaleString()}
+ Balance {formatValue(balance)}
+ You will get
+
+ {calculateMinesMultiplier(isPlaying ? revealedTiles.length + 1 : 1, mineCount, betAmount).toFixed(2)}x
+
+ per tile, probability of winning:
+
+ {calculateProbability(isPlaying ? 1 : 1, mineCount)}%
+
+
+ Max bet: {MAX_BET_AMOUNT.toLocaleString()}
+