Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
aidansunbury authored Jan 15, 2025
2 parents 63534b4 + f50f3c5 commit 59eec32
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .changeset/gold-beans-kiss.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-t3-app": patch
---

fix: cli cancel not working
16 changes: 8 additions & 8 deletions cli/src/helpers/scaffoldProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,22 @@ export const scaffoldProject = async ({
],
initialValue: "abort",
});
if (overwriteDir === "abort") {

if (p.isCancel(overwriteDir) || overwriteDir === "abort") {
spinner.fail("Aborting installation...");
process.exit(1);
}

const overwriteAction =
overwriteDir === "clear"
? "clear the directory"
: "overwrite conflicting files";

const confirmOverwriteDir = await p.confirm({
message: `Are you sure you want to ${overwriteAction}?`,
message: `Are you sure you want to ${
overwriteDir === "clear"
? "clear the directory"
: "overwrite conflicting files"
}?`,
initialValue: false,
});

if (!confirmOverwriteDir) {
if (p.isCancel(confirmOverwriteDir) || !confirmOverwriteDir) {
spinner.fail("Aborting installation...");
process.exit(1);
}
Expand Down
1 change: 1 addition & 0 deletions cli/template/base/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"resolveJsonModule": true,
"moduleDetection": "force",
"isolatedModules": true,
"verbatimModuleSyntax": true,

/* Strictness */
"strict": true,
Expand Down
7 changes: 7 additions & 0 deletions www/src/components/docs/openSourceAppList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,13 @@ const projects: App[] = [
linkName: "Ray",
link: "https://koujialong-ray.vercel.app/",
},
{
description: "Aiseka - Discover the best Color Palette & Color Tools",
repoName: "meetqy/aiseka",
repo: "https://github.com/meetqy/aiseka",
linkName: "AISEKA",
link: "https://aiseka.com/",
},
];

export default function OpenSourceAppList({
Expand Down
78 changes: 74 additions & 4 deletions www/src/pages/en/usage/drizzle.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,79 @@ lang: en
isMdx: true
---

import Callout from "../../../components/docs/callout.tsx";
Drizzle is a headless Typescript ORM with [relational](https://orm.drizzle.team/docs/rqb) and [SQL-like](https://orm.drizzle.team/docs/select) query APIs. It can handle database migrations and schemas, and provides a type safe database client. It also comes with [Drizzle-Kit](https://orm.drizzle.team/drizzle-studio/overview), a set of companion tools that help with querying your database.

<Callout type="info">
The `drizzle` option is a new addition and no docs have yet been written. Contributions are welcome!
## Drizzle Client

</Callout>
The Drizzle Client is located at `src/server/db/index.ts`. In this file, you can define your database connection url and connect your schema to the database object.

```ts:src/server/db/index.ts
import { env } from "~/env";
import * as schema from "./schema";
import postgres from "postgres";


const conn = postgres(env.DATABASE_URL)

export const db = drizzle(conn, { schema });
```

We reccommend including the database client in your tRPC Context:

```ts:src/server/api/trpc.ts
import { db } from "~/server/db";

export const createTRPCContext = async (opts: { headers: Headers }) => {
const session = await auth();

return {
db,
session,
...opts,
};
};
```

## Schema

The Drizzle schema file can be found at `src/server/db/schema.ts`. This file is where you can define your database schema and models, and connects to the Drizzle Client.

When you select NextAuth.js in combination with Prisma, the schema file is generated and set up for you with the recommended values for the `User`, `Session`, `Account`, and `VerificationToken` models, as per the [Auth.js documentation](https://authjs.dev/getting-started/adapters/drizzle).

## Drizzle Kit

Drizzle Kit is a collection of command line tools designed to help you manage your database. T3 Stack automatically includes drizzle kit when you select Drizzle as your ORM.

```json:package.json
"scripts": {
...
"db:generate": "drizzle-kit generate",
"db:migrate": "drizzle-kit migrate",
"db:push": "drizzle-kit push",
"db:studio": "drizzle-kit studio",
...
},
```

### Script Explanations

`db:generate`
Generates TypeScript types and models from your database schema, ensuring type safety and easy integration with Drizzle ORM.

`db:migrate`
Applies pending migrations to your database, keeping your schema in sync with changes and updates in your project.

`db:push`
Pushes local schema changes directly to the database without needing explicit migration files. This can be useful for quick syncing in development.

`db:studio`
Opens a visual interface for managing and inspecting your database tables, data, and relationships.

## Useful Resources

| Resource | Link |
| --------------------------- | --------------------------------------------------- |
| Drizzle Docs | https://orm.drizzle.team/docs/overview |
| Drizzle GitHub | https://github.com/drizzle-team/drizzle-orm |
| Auth.JS Drizzle Adapter | https://authjs.dev/getting-started/adapters/drizzle |
| Drizzle Kit Migration Guide | https://orm.drizzle.team/docs/kit-overview |

0 comments on commit 59eec32

Please sign in to comment.