Skip to content
This repository was archived by the owner on Mar 9, 2026. It is now read-only.

Latest commit

 

History

History
55 lines (43 loc) · 1.73 KB

File metadata and controls

55 lines (43 loc) · 1.73 KB

Catalog Audit DB

Handles schemas for various tables including:

  • track_plays: logs each track play in the next-app, tying it to user if they are logged in.
  • purchases: logs each purchase attempt, tracking the status of the purchase.
  • purchase_methods: enum table of purchase types (PayPal, Credit/Debit Card, USDC, Apple Pay)
  • purchase_status: enum table of purchase statuses (inflight, processing, confirmed, error)

Purchase Status

  1. The next-app first creates an purchases row with status=inflight when a user purchases with fiat.
  2. Once the catalog-rest-api receives a webhook from PayPal we set it to processing.
  3. When we actually complete an onchain transaction to fulfill it, we set it to confirmed.

Track Plays

  1. Whenever a track begins playing in the next-app, we create a row in the track_plays table.
  2. After 30 seconds we update the listen duration to 30 seconds.
  3. Upon finishing the track, we update the listen duration to the full duration of the track.

Setup

Prerequisites

  • Bun
  • Doppler CLI

Installation

bun install

Creating Migrations

Make changes in the entities directory

Generate migration with

bun migrate:generate

Running Migrations

Apply Migrations

bun migrate

Rollback Migrations

bun migrate:down

Environment

  • Ensure Doppler is configured (using the catalog-radio project)

Deploying

  • The above migration scripts apply migrations directly to the production instance of the database.
  • The production instance lives on railway under the catalog-audit-db project.
  • You can view the tables, and find the commands to connect to this database on railway as well.