sqlite.ts — drizzle-orm Source File
Architecture documentation for sqlite.ts, a typescript file in the drizzle-orm codebase. 6 imports, 8 dependents.
Entity Profile
Dependency Diagram
graph LR 340acff6_8c1f_b0b5_9358_222e8b76d050["sqlite.ts"] 217e2cbd_4fb7_ceab_251c_5733ece08a8f["views.ts"] 340acff6_8c1f_b0b5_9358_222e8b76d050 --> 217e2cbd_4fb7_ceab_251c_5733ece08a8f b0ef3d06_896b_eefc_c410_dfb419673d70["error"] 340acff6_8c1f_b0b5_9358_222e8b76d050 --> b0ef3d06_896b_eefc_c410_dfb419673d70 9135e6b6_37f7_c980_ee35_90f5531de5a4["common.ts"] 340acff6_8c1f_b0b5_9358_222e8b76d050 --> 9135e6b6_37f7_c980_ee35_90f5531de5a4 b00190f0_9c7c_acbf_86f7_950ac8c79592["wrapParam"] 340acff6_8c1f_b0b5_9358_222e8b76d050 --> b00190f0_9c7c_acbf_86f7_950ac8c79592 01e00b35_5de9_4e4e_2b6b_d50401fec78b["global"] 340acff6_8c1f_b0b5_9358_222e8b76d050 --> 01e00b35_5de9_4e4e_2b6b_d50401fec78b 9d8cc145_835b_8147_2ea5_b7b5383ae775["zod"] 340acff6_8c1f_b0b5_9358_222e8b76d050 --> 9d8cc145_835b_8147_2ea5_b7b5383ae775 e668bfef_9125_1ef0_2f94_a0f9605584bd["api.ts"] e668bfef_9125_1ef0_2f94_a0f9605584bd --> 340acff6_8c1f_b0b5_9358_222e8b76d050 c2c22050_0d5c_404e_2b18_5934c728a89c["introspect.ts"] c2c22050_0d5c_404e_2b18_5934c728a89c --> 340acff6_8c1f_b0b5_9358_222e8b76d050 6219550e_1686_ca7a_0d96_0838fb90e7cb["push.ts"] 6219550e_1686_ca7a_0d96_0838fb90e7cb --> 340acff6_8c1f_b0b5_9358_222e8b76d050 cea479b5_7704_0339_de4e_3cc844834ec0["sqliteIntrospect.ts"] cea479b5_7704_0339_de4e_3cc844834ec0 --> 340acff6_8c1f_b0b5_9358_222e8b76d050 09e5bcf1_0f03_3dbd_fbdb_762440f28855["utils.ts"] 09e5bcf1_0f03_3dbd_fbdb_762440f28855 --> 340acff6_8c1f_b0b5_9358_222e8b76d050 4e02c2bb_54a8_1500_813e_2cafd1ad4f59["connections.ts"] 4e02c2bb_54a8_1500_813e_2cafd1ad4f59 --> 340acff6_8c1f_b0b5_9358_222e8b76d050 b30392fa_f107_a197_96c4_0d1a6ce594a2["studio.ts"] b30392fa_f107_a197_96c4_0d1a6ce594a2 --> 340acff6_8c1f_b0b5_9358_222e8b76d050 82de12f8_a8ca_9d38_8da8_9ac945d81e01["studio.ts"] 82de12f8_a8ca_9d38_8da8_9ac945d81e01 --> 340acff6_8c1f_b0b5_9358_222e8b76d050 style 340acff6_8c1f_b0b5_9358_222e8b76d050 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { softAssertUnreachable } from 'src/global';
import { literal, object, string, TypeOf, undefined, union } from 'zod';
import { error } from '../views';
import { sqliteDriver, wrapParam } from './common';
export const sqliteCredentials = union([
object({
driver: literal('turso'),
url: string().min(1),
authToken: string().min(1).optional(),
}),
object({
driver: literal('d1-http'),
accountId: string().min(1),
databaseId: string().min(1),
token: string().min(1),
}),
object({
driver: undefined(),
url: string().min(1),
}).transform<{ url: string }>((o) => {
delete o.driver;
return o;
}),
]);
export type SqliteCredentials =
| {
driver: 'd1-http';
accountId: string;
databaseId: string;
token: string;
}
| {
url: string;
};
const _: SqliteCredentials = {} as TypeOf<typeof sqliteCredentials>;
export const printConfigConnectionIssues = (
options: Record<string, unknown>,
command: 'generate' | 'migrate' | 'push' | 'pull' | 'studio',
) => {
const parsedDriver = sqliteDriver.safeParse(options.driver);
const driver = parsedDriver.success ? parsedDriver.data : ('' as never);
if (driver === 'expo') {
if (command === 'migrate') {
console.log(
error(
`You can't use 'migrate' command with Expo SQLite, please follow migration instructions in our docs - https://orm.drizzle.team/docs/get-started-sqlite#expo-sqlite`,
),
);
} else if (command === 'studio') {
console.log(
error(
`You can't use 'studio' command with Expo SQLite, please use Expo Plugin https://www.npmjs.com/package/expo-drizzle-studio-plugin`,
),
);
} else if (command === 'pull') {
console.log(error("You can't use 'pull' command with Expo SQLite"));
} else if (command === 'push') {
console.log(error("You can't use 'push' command with Expo SQLite"));
} else {
console.log(error('Unexpected error with expo driver 🤔'));
}
process.exit(1);
} else if (driver === 'd1-http') {
let text = `Please provide required params for D1 HTTP driver:\n`;
console.log(error(text));
console.log(wrapParam('accountId', options.accountId));
console.log(wrapParam('databaseId', options.databaseId));
console.log(wrapParam('token', options.token, false, 'secret'));
process.exit(1);
} else if (driver === 'durable-sqlite') {
if (command === 'migrate') {
console.log(
error(
`You can't use 'migrate' command with SQLite Durable Objects`,
),
);
} else if (command === 'studio') {
console.log(
error(
`You can't use 'studio' command with SQLite Durable Objects`,
),
);
} else if (command === 'pull') {
console.log(error("You can't use 'pull' command with SQLite Durable Objects"));
} else if (command === 'push') {
console.log(error("You can't use 'push' command with SQLite Durable Objects"));
} else {
console.log(error('Unexpected error with SQLite Durable Object driver 🤔'));
}
process.exit(1);
} else {
softAssertUnreachable(driver);
}
let text = `Please provide required params:\n`;
console.log(error(text));
console.log(wrapParam('url', options.url));
process.exit(1);
};
Domain
Subdomains
Types
Imported By
Source
Frequently Asked Questions
What does sqlite.ts do?
sqlite.ts is a source file in the drizzle-orm codebase, written in typescript. It belongs to the DrizzleKit domain, CLIWorkflow subdomain.
What functions are defined in sqlite.ts?
sqlite.ts defines 2 function(s): printConfigConnectionIssues, sqliteCredentials.
What does sqlite.ts depend on?
sqlite.ts imports 6 module(s): common.ts, error, global, views.ts, wrapParam, zod.
What files import sqlite.ts?
sqlite.ts is imported by 8 file(s): api.ts, connections.ts, introspect.ts, push.ts, sqliteIntrospect.ts, studio.ts, studio.ts, utils.ts.
Where is sqlite.ts in the architecture?
sqlite.ts is located at drizzle-kit/src/cli/validations/sqlite.ts (domain: DrizzleKit, subdomain: CLIWorkflow, directory: drizzle-kit/src/cli/validations).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free