Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Mef45 opened this issue Jan 31, 2025 · 0 comments · Fixed by #433
Closed
Labels
bug Something isn't working pkg:add sv add

Comments

@Mef45
Copy link

Mef45 commented Jan 31, 2025

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;
@manuel3108 manuel3108 added bug Something isn't working help wanted Extra attention is needed pkg:add sv add question Further information is requested and removed bug Something isn't working help wanted Extra attention is needed question Further information is requested labels Feb 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pkg:add sv add
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants