Skip to Content

Database Configuration

Auktiva supports two database options: SQLite for simple local deployments and Turso for cloud-based, distributed databases.

SQLite (Default)

SQLite is the simplest option, storing data in a local file. Perfect for:

  • Development environments
  • Single-server deployments
  • Small to medium workloads

Configuration

DATABASE_URL="file:./data/auktiva.db"

The path is relative to the project root. The directory will be created automatically.

Advantages

  • Zero configuration
  • No external dependencies
  • Fast for local access
  • Easy backups (just copy the file)

Limitations

  • Single server only (no horizontal scaling)
  • File must be on local filesystem
  • Not suitable for serverless deployments (Vercel, etc.)

Turso  is a distributed SQLite database built on libSQL. It provides:

  • Edge-replicated databases
  • Serverless-friendly
  • SQLite compatibility
  • Generous free tier

Setting Up Turso

  1. Create a Turso account at turso.tech 

  2. Install the Turso CLI:

# macOS brew install tursodatabase/tap/turso # Linux curl -sSfL https://get.tur.so/install.sh | bash
  1. Authenticate:
turso auth login
  1. Create a database:
turso db create auktiva
  1. Get the connection URL:
turso db show auktiva --url # Output: libsql://auktiva-yourusername.turso.io
  1. Create an auth token:
turso db tokens create auktiva # Output: eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9...

Configuration

DATABASE_URL="libsql://auktiva-yourusername.turso.io" DATABASE_AUTH_TOKEN="eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9..."

Database Commands

Auktiva provides several npm scripts for database management:

CommandDescription
npm run db:generateGenerate Prisma client
npx prisma migrate deployApply migrations (SQLite)
npm run db:migrate:tursoApply migrations (Turso)
npm run db:pushPush schema without migrations (development only)
npm run db:studioOpen Prisma Studio (GUI)
npm run seed:currenciesSeed currency data
npm run seedSeed sample data (development)

Initial Setup

After configuring your database:

# Generate the Prisma client npm run db:generate # Apply the migrations: SQLite npx prisma migrate deploy # ... or Turso npm run db:migrate:turso # Seed required data npm run seed:currencies

Viewing Data

Use Prisma Studio to browse and edit data:

npm run db:studio

This opens a web interface at http://localhost:5555.

Schema Overview

Auktiva uses the following main tables:

  • users - User accounts
  • accounts - OAuth provider accounts (NextAuth)
  • sessions - Active sessions
  • auctions - Auction listings
  • auction_members - Auction membership and roles
  • auction_items - Items within auctions
  • item_images - Images for auction items
  • bids - Bid history
  • currencies - Supported currencies
  • notifications - User notifications
  • user_settings - User preferences

Winner Notification Fields

Each row in auction_items records whether its winner has been told and who that was:

FieldTypeMeaning
winnerNotifiedBooleanfalse means a win notification is pending for whoever is the highest bidder when the item ends
winnerNotifiedUserIdString?The user last told they won (a plain user ID, like highestBidderId)
winnerNotifiedAmountFloat?The item’s currentBid when that user was recorded
winnerNotifiedAtDateTime?When the notified winner was recorded

The auction-end notifier (src/lib/services/auction-end.service.ts) selects published items that have ended, have a highest bidder and have winnerNotified = false. An item has ended when its own endDate has passed, or, if it has none, when its auction’s endDate has passed. The notifier claims each item with one conditional update that sets winnerNotified = true and writes the three record fields. Only the run whose claim succeeds sends the in-app notification and the item-won e-mail, so overlapping runs notify a winner at most once. If creating the in-app notification fails before anything was stored, the claim is released for a later run.

Items whose effective end is more than 14 days before the claim (STALE_WINNER_NOTIFICATION_MS) are recorded without sending anything.

Reopening bidding sets winnerNotified = false on every item that goes from closed to open and keeps the other three fields. The next close then notifies whoever wins at that point.

Notification and E-mail Types

NotificationType and EmailType both include BIDDING_REOPENED. It is used for the notice sent to bidders when bidding reopens, and for the e-mail sent to previous winners who enabled item-won e-mails. SQLite stores enums as text, so the new value needs no SQL change, but run npm run db:generate to update the Prisma client.

Migrations in v1.23.0

Two migrations come with this release:

  • 20261122170000_mark_past_null_dated_winners_notified marks winners of items without their own end date in auctions that had already ended as notified. This stops a burst of late “won” notifications now that these items end with their auction.
  • 20261122180000_add_winner_notification_record adds the three record columns. For items already marked as notified, it fills in the user and time from the item’s latest AUCTION_WON notification, or the current highest bidder when that notification is gone. Items whose recorded winner is no longer the highest bidder become pending again, so the new winner is told once the item has ended. The exception is items whose effective end (their own end date, else the auction’s) was more than 14 days before the upgrade. For those, the current highest bidder is recorded and nobody is messaged.

See Upgrading for how to apply them and what to check.

Backups

SQLite Backups

Simply copy the database file:

cp ./data/auktiva.db ./backups/auktiva-$(date +%Y%m%d).db

Turso Backups

Turso automatically handles backups. You can also export data:

turso db shell auktiva ".dump" > backup.sql
Last updated on