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 (Recommended for Production)
Turso is a distributed SQLite database built on libSQL. It provides:
- Edge-replicated databases
- Serverless-friendly
- SQLite compatibility
- Generous free tier
Setting Up Turso
-
Create a Turso account at turso.techÂ
-
Install the Turso CLI:
# macOS
brew install tursodatabase/tap/turso
# Linux
curl -sSfL https://get.tur.so/install.sh | bash- Authenticate:
turso auth login- Create a database:
turso db create auktiva- Get the connection URL:
turso db show auktiva --url
# Output: libsql://auktiva-yourusername.turso.io- 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:
| Command | Description |
|---|---|
npm run db:generate | Generate Prisma client |
npx prisma migrate deploy | Apply migrations (SQLite) |
npm run db:migrate:turso | Apply migrations (Turso) |
npm run db:push | Push schema without migrations (development only) |
npm run db:studio | Open Prisma Studio (GUI) |
npm run seed:currencies | Seed currency data |
npm run seed | Seed 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:currenciesViewing Data
Use Prisma Studio to browse and edit data:
npm run db:studioThis 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:
| Field | Type | Meaning |
|---|---|---|
winnerNotified | Boolean | false means a win notification is pending for whoever is the highest bidder when the item ends |
winnerNotifiedUserId | String? | The user last told they won (a plain user ID, like highestBidderId) |
winnerNotifiedAmount | Float? | The itemâs currentBid when that user was recorded |
winnerNotifiedAt | DateTime? | 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_notifiedmarks 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_recordadds the three record columns. For items already marked as notified, it fills in the user and time from the itemâs latestAUCTION_WONnotification, 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).dbTurso Backups
Turso automatically handles backups. You can also export data:
turso db shell auktiva ".dump" > backup.sql