Merged
Conversation
- Add Drizzle ORM and Drizzle Kit dependencies and configuration. - Define initial database schema for users and generate migrations. - Create `useDB` utility for type-safe database access in server routes. - Implement GitHub Actions for staging and production deployments. - Update `wrangler.jsonc` with D1 bindings and environment settings. - Expand README with database architecture and migration guides. Enable persistent storage and automated deployment pipelines to ensure database schema consistency across environments. Using Drizzle with D1 provides a serverless SQL solution at the edge with a developer-friendly migration workflow.
Add a new `StagingEnv` interface and update the main `Env` interface to reflect changes in the Cloudflare Worker configuration. Optional bindings are now correctly marked as such to improve type safety. These changes are necessary to support staging-specific environment variables and to accurately represent which bindings are guaranteed to be present at runtime. The file has also been reformatted to use consistent indentation.
Standardize indentation to 2 spaces across the entire file. Improve the readability of complex union types and interface definitions by breaking them into multiple lines. This ensures the generated type definitions align with the project's formatting standards.
- Create `AGENTS.md` with project overview, commands, and patterns. - Add `CLAUDE.md` as a reference to the agent guide. - Remove AI context files from `.gitignore` to track them in the repository. Provide AI assistants and developers with clear context on the project architecture and workflows to improve development efficiency. Tracking these files ensures instructions are shared across the team and available to AI tools.
Update @unhead/vue to version 2.1.4 and add @types/node to the project dependencies. Modify tsconfig.json to enable strict type checking and enforce consistent casing in filenames. These changes keep dependencies up to date, provide better type safety for Node.js APIs, and enforce stricter coding standards to prevent potential runtime errors and cross-platform file naming issues.
Replace "latest" version tags with explicit version numbers for all dependencies and devDependencies in the lockfile. Using "latest" makes builds non-deterministic and prone to breaking when upstream packages release updates. Pinning these versions ensures environment stability and consistent behavior across different installations.
Rename `db:migrate:local` to `db:migrate` in package.json and AGENTS.md. Remove the extensive database documentation section from README.md. The database documentation is removed from the main README to keep the file concise and focused on the project overview. The migration script is renamed to provide a shorter and more standard command for local development.
daveio/database workflow
- Move staging deployment logic into `ci.yaml` - Update production deployment trigger to use `production` branch - Remove redundant `.github/workflows/staging.yaml` file - Update `worker-configuration.d.ts` by removing unused types Centralizing the CI/CD pipeline into a single file improves maintainability and ensures consistent build steps across environments. Updating the production branch reference aligns the workflow with the project's branching strategy.
Contributor
There was a problem hiding this comment.
Pull request overview
Integrates Drizzle ORM + D1 into the Nuxt/Cloudflare Workers stack, adds initial schema/migrations, and introduces staging/production deployment automation with environment-specific D1 configuration.
Changes:
- Add Drizzle ORM/Kit configuration, initial
usersschema, and generated D1 migrations. - Introduce a
useDBhelper for type-safe access to the Cloudflare D1 binding from Nitro server handlers. - Extend Wrangler + CI to support a staging environment and automated migrations/deploys on staging/production branches.
Reviewed changes
Copilot reviewed 16 out of 20 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
wrangler.jsonc |
Adds migrations_dir and defines env.staging with its own D1 binding. |
worker-configuration.d.ts |
Updates generated Cloudflare environment typing (incl. optional bindings + staging env type). |
tsconfig.json |
Enables strict mode and adds Node types. |
server/utils/db.ts |
Adds useDB(event) helper returning a Drizzle D1 client bound to the Worker DB. |
server/database/schema.ts |
Introduces initial users table schema. |
server/database/migrations/** |
Adds initial SQL migration and Drizzle migration metadata. |
server/database/index.ts |
Re-exports schema module. |
package.json |
Adds Drizzle dependencies and DB tooling scripts (generate/migrate/push/studio). |
drizzle.config.ts |
Adds Drizzle Kit config targeting D1 HTTP driver and env-based credentials. |
bun.lock |
Lockfile updates for new/updated dependencies. |
README.md |
Updates project structure docs to include server/database and server/utils. |
PROMPTS.md |
Adds agent prompt documentation for DB workflows. |
AGENTS.md |
Adds agent/developer workflow guide covering DB and deployment commands. |
CLAUDE.md |
Adds agent guide file (currently duplicates the guide content). |
.trunk/trunk.yaml |
Bumps trufflehog linter version. |
.gitignore |
Stops ignoring AI context files so they can be committed. |
.github/workflows/ci.yaml |
Adds staging + production deploy jobs including migration steps. |
.env.example |
Adds CLOUDFLARE_DATABASE_ID placeholder. |
Comments suppressed due to low confidence (1)
CLAUDE.md:3
CLAUDE.mdcurrently contains a full copy of the agent guide content rather than just referencingAGENTS.mdas described in the PR. Duplicating the same guide in two files will likely drift over time; prefer makingCLAUDE.mda short pointer (or a symlink) toAGENTS.mdso there’s a single source of truth.
# Agent Guide for Affirm
This document outlines the development workflow, commands, and patterns for working in this codebase.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+52
to
+55
| deploy-staging: | ||
| runs-on: ubuntu-latest | ||
| if: github.ref == 'refs/heads/staging' && github.event_name == 'push' | ||
| steps: |
There was a problem hiding this comment.
deploy-staging does not depend on the lint job, so it can deploy even when lint/typecheck/build fails (jobs run in parallel by default). Add needs: lint (and/or gate with if: success()) to prevent deploying broken commits to staging.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🗃️ (db): integrate Drizzle ORM with Cloudflare D1 and setup CI/CD
useDButility for type-safe database access in server routes.wrangler.jsoncwith D1 bindings and environment settings.Enable persistent storage and automated deployment pipelines to ensure
database schema consistency across environments. Using Drizzle with D1
provides a serverless SQL solution at the edge with a developer-friendly
migration workflow.
🏷️ (worker-configuration.d.ts): update environment types and formatting
Add a new
StagingEnvinterface and update the mainEnvinterface toreflect changes in the Cloudflare Worker configuration. Optional
bindings are now correctly marked as such to improve type safety.
These changes are necessary to support staging-specific environment
variables and to accurately represent which bindings are guaranteed to
be present at runtime. The file has also been reformatted to use
consistent indentation.
🎨 (worker-configuration.d.ts): reformat with consistent indentation
Standardize indentation to 2 spaces across the entire file. Improve the
readability of complex union types and interface definitions by breaking
them into multiple lines. This ensures the generated type definitions
align with the project's formatting standards.
🌈 sync
📝 Add AI agent development guide and track context files
AGENTS.mdwith project overview, commands, and patterns.CLAUDE.mdas a reference to the agent guide..gitignoreto track them in the repository.Provide AI assistants and developers with clear context on the project
architecture and workflows to improve development efficiency. Tracking
these files ensures instructions are shared across the team and available
to AI tools.
⬆️ Upgrade @unhead/vue and enhance TypeScript configuration
Update @unhead/vue to version 2.1.4 and add @types/node to the project
dependencies. Modify tsconfig.json to enable strict type checking and
enforce consistent casing in filenames.
These changes keep dependencies up to date, provide better type safety
for Node.js APIs, and enforce stricter coding standards to prevent
potential runtime errors and cross-platform file naming issues.
📌 Pin dependencies to specific versions
Replace "latest" version tags with explicit version numbers for all
dependencies and devDependencies in the lockfile.
Using "latest" makes builds non-deterministic and prone to breaking when
upstream packages release updates. Pinning these versions ensures
environment stability and consistent behavior across different
installations.
📝 simplify database documentation and rename migration script
Rename
db:migrate:localtodb:migratein package.json and AGENTS.md.Remove the extensive database documentation section from README.md.
The database documentation is removed from the main README to keep the
file concise and focused on the project overview. The migration script is
renamed to provide a shorter and more standard command for local
development.
👷 Consolidate CI workflows and update deployment branches
ci.yamlproductionbranch.github/workflows/staging.yamlfileworker-configuration.d.tsby removing unused typesCentralizing the CI/CD pipeline into a single file improves
maintainability and ensures consistent build steps across environments.
Updating the production branch reference aligns the workflow with the
project's branching strategy.