Course lesson 08 · Building in a Mono Repo

Setting up D1 Database & Drizzle ORM

One study unit · Read, recall, then practice · Original video 00:17:49

The course creates a D1 database and uses Drizzle to represent its tables as TypeScript schemas. Schema and query code lives in Data Ops so both applications can share it, and database initialization is centralized to reduce provider-specific setup scattered through the apps. This lesson uses a database-first workflow: create tables remotely, then introspect them into code.

Primary source: course video 08 · Supplied English subtitles · 00:17:49.

Understand the idea

What the course does

  1. Create a Smart Links database with a stage suffix to prepare for later environment separation.
  2. Put the account and database identifiers and a D1-capable API token in the Data Ops tooling environment file.
  3. Configure Drizzle output paths and run an initial pull to confirm connectivity.
  4. Use the database query interface and supplied course SQL to create links, link clicks, indexes, and destination evaluations.
  5. Pull again and inspect the generated TypeScript schemas in the shared package.

Watch for

Recall before revealing

Why is the first schema pull empty, and why does the second contain tables?

Reveal the explanation

The first runs before any tables exist; the second introspects the tables just created in D1.

Try it

Create the course’s three tables in a dedicated study database and explain what event or action writes to each one.

Check your result

The generated schemas match the database tables, and you can distinguish link configuration, click history, and evaluation results.

Practice prompts and answer checks are added teaching material. Answer from memory first, then compare and explain any difference.

Rewatch only what you need

Open this lesson in your original course library and seek to the times below. Videos are not hosted on this site.

Companion primary documentation: Drizzle with Cloudflare D1. For recorded API names, commands, limits, and prices, check the version you use.

← Previous   Next →