Skip to content

Improve drizzle-orm SQLite default template #484

@hyunbinseo

Description

@hyunbinseo

As of Svelte CLI v0.6.26

  • db:generate is not included in the scripts:
  "db:push": "drizzle-kit push",
  "db:migrate": "drizzle-kit migrate",
  "db:studio": "drizzle-kit studio"
  "db:migrate": "drizzle-kit migrate", // missing
  • Unused variable is included in the schema.ts file:
// 'text' is declared but its value is never read.ts(6133)
import { sqliteTable, text, integer } from 'drizzle-orm/sqlite-core';

export const user = sqliteTable('user', {
  id: integer('id').primaryKey(),
  age: integer('age')
});
  • Line-breaks are missing in the drizzle.config.ts file:
import { defineConfig } from 'drizzle-kit';
if (!process.env.DATABASE_URL) throw new Error('DATABASE_URL is not set');
  • loadEnvFile should probably be called in the drizzle.config.ts file:
import { defineConfig } from 'drizzle-kit';
import { loadEnvFile } from 'node:process';

loadEnvFile();

if (!process.env.DATABASE_URL) throw new Error('DATABASE_URL is not set');
  • @types/node should probably be installed out-of-the box.
import { defineConfig } from 'drizzle-kit';

// Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.ts(2580)
if (!process.env.DATABASE_URL) throw new Error('DATABASE_URL is not set');
  • Line-breaks are missing in the src\lib\server\db\index.ts file:
import { drizzle } from 'drizzle-orm/libsql';
import { createClient } from '@libsql/client';
import * as schema from './schema';
import { env } from '$env/dynamic/private';
if (!env.DATABASE_URL) throw new Error('DATABASE_URL is not set');
const client = createClient({ url: env.DATABASE_URL });

Are there reasons behind these decisions? If not, I would love to create a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions