Skip to content

Invalid content in schema.ts when creating new project with Lucia, Drizzle, SQLite and Turso #431

@Mef45

Description

@Mef45

When selecting SQLite as the database and Turso as the client, the content in schema.ts is generated incorrectly. Other client combinations for SQLite do not have this issue.

Steps to reproduce:

  1. Start creating a new project using sv create
  2. Select drizzle, lucia as add-ons
  3. Choose SQLite as the database
  4. Choose Turso as the SQLite client
  5. Wait until the project setup is complete
  6. Observe incorrect content in the file src/lib/server/db/schema.ts
src/lib/server/db/schema.ts
import { sqliteTable, text, integer } from 'drizzle-orm/sqlite-core';

export const user = sqliteTable('user', {
	id: integer('id').primaryKey(),
	age: integer('age')
});
export const session = undefined('session', {});

export type Session = typeof session.$inferSelect;

export type User = typeof user.$inferSelect;
CLI output
pnpx sv create
┌  Welcome to the Svelte CLI! (v0.6.18)
│
◇  Where would you like your project to be created?
│  ./
│
◇  Which template would you like?
│  SvelteKit minimal
│
◇  Add type checking with Typescript?
│  Yes, using Typescript syntax
│
◆  Project created
│
◇  What would you like to add to your project? (use arrow keys / space bar)
│  prettier, eslint, vitest, sveltekit-adapter, drizzle, lucia
│
◇  sveltekit-adapter: Which SvelteKit adapter would you like to use?
│  node
│
◇  drizzle: Which database would you like to use?
│  SQLite
│
◇  drizzle: Which SQLite client would you like to use?
│  Turso
│
◇  lucia: Do you want to include a demo? (includes a login/register page)
│  Yes
│
◇  Which package manager do you want to install dependencies with?
│  pnpm
│
◆  Successfully setup add-ons
│
◆  Successfully installed dependencies
│
◇  Successfully formatted modified files
│
◇  Project next steps ─────────────────────────────────────────────────────╮
│                                                                          │
│  1: git init && git add -A && git commit -m "Initial commit" (optional)  │
│  2: pnpm run dev --open                                                  │
│                                                                          │
│  To close the dev server, hit Ctrl-C                                     │
│                                                                          │
│  Stuck? Visit us at https://svelte.dev/chat                              │
│                                                                          │
├──────────────────────────────────────────────────────────────────────────╯
│
◇  Add-on next steps ──────────────────────────────────────────────────╮
│                                                                      │
│  drizzle:                                                            │
│  - You will need to set DATABASE_URL in your production environment  │
│  - Run pnpm run db:push to update your database schema               │
│                                                                      │
│  lucia:                                                              │
│  - Run pnpm run db:push to update your database schema               │
│  - Visit /demo/lucia route to view the demo                          │
│                                                                      │
├──────────────────────────────────────────────────────────────────────╯
│
└  You're all set!

schema.ts for SQLite with better-sqlite3 as the client for comparison
import { sqliteTable, text, integer } from 'drizzle-orm/sqlite-core';

export const user = sqliteTable('user', {
    id: text('id').primaryKey(),
    age: integer('age'),
    username: text('username').notNull().unique(),
    passwordHash: text('password_hash').notNull()
});

export const session = sqliteTable("session", {
    id: text('id').primaryKey(),
    userId: text('user_id').notNull().references(() => user.id),
    expiresAt: integer('expires_at', { mode: 'timestamp' }).notNull()
});

export type Session = typeof session.$inferSelect;

export type User = typeof user.$inferSelect;

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpkg:addsv add

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions