D1 multi tenant improvements and test coverage#50
Open
ataylorme wants to merge 29 commits intozpg6:feat/d1-multi-tenancyfrom
Open
D1 multi tenant improvements and test coverage#50ataylorme wants to merge 29 commits intozpg6:feat/d1-multi-tenancyfrom
ataylorme wants to merge 29 commits intozpg6:feat/d1-multi-tenancyfrom
Conversation
Co-authored-by: ataylorme <2133004+ataylorme@users.noreply.github.com>
Co-authored-by: ataylorme <2133004+ataylorme@users.noreply.github.com>
Co-authored-by: ataylorme <2133004+ataylorme@users.noreply.github.com>
Co-authored-by: ataylorme <2133004+ataylorme@users.noreply.github.com>
Co-authored-by: ataylorme <2133004+ataylorme@users.noreply.github.com>
- Add comprehensive schema detection and validation utilities - Add tests for plugin table placement and relationships - Document how to handle Better Auth plugins with multi-tenancy - Add 24 new tests for schema management (all passing) - Provide utilities to detect cross-database references - Document migration strategies for plugin-added tables Co-authored-by: ataylorme <2133004+ataylorme@users.noreply.github.com>
Implement Universal ID-based sharding for D1 multi-tenancy with plugin support
…nges Co-authored-by: ataylorme <2133004+ataylorme@users.noreply.github.com>
…mentation Update examples and documentation for PR #1 Universal ID sharding
Co-authored-by: ataylorme <2133004+ataylorme@users.noreply.github.com>
Add full test coverage for D1 multi-tenancy features with Drizzle mocking
…store Co-authored-by: ataylorme <2133004+ataylorme@users.noreply.github.com>
Co-authored-by: ataylorme <2133004+ataylorme@users.noreply.github.com>
Add Cloudflare KV as persistent L2 backing store for the shard cache
- Migrate from Jest to Vitest with ESM support and vi.hoisted() for mock hoisting - Add @faker-js/faker for realistic test data generation - Add nock for HTTP-level Cloudflare D1 API mocking in integration tests - Add drizzle-kit and wrangler as dev dependencies - Add new sharding-multi-db test suite covering: - Multi-DB routing via Universal IDs - Batch tenant creation with unique UUIDs - Shard cache population and FIFO eviction under load - Database full/limit exceeded error handling - Migration failure during DB initialization - Data validation across shards (deterministic hashes, status transitions) - Add integration-sharding test suite covering: - Full tenant lifecycle (create + delete) for user and org modes - Batch creation of 10 tenants with nock interceptors - Error recovery: API limits, HTTP 500, 403, network timeouts - Shard cache hydration from adapter with 25 tenants - Universal ID routing across 5 shard databases - KV write-through during tenant creation - Concurrent tenant creation - Schema SQL execution with statement breakpoints - Create GitHub Actions test.yml workflow with: - Unit/integration tests on Node 20, 22, 24 - Typecheck job - Matrix-based sharding scenario jobs running each test file independently Total: 181 tests across 9 test files, all passing. https://claude.ai/code/session_013ggvpkaVD7QivK8XaS4YMB
- Use getPlatformProxy() with wrangler.test.toml to provide 10 real
SQLite-backed D1 database bindings for testing
- Replace all vi.mock("@zpg6-test-pkgs/drizzle-orm/d1-http") stubs with
a redirector that routes drizzle calls to real D1 bindings via the d1
binding driver
- Remove all nock HTTP mocking from integration tests
- Replace fetch mocks for Cloudflare REST API (create/delete database)
with createLocalD1Fetch interceptor that performs real local D1 ops
- Add node:fs verification helpers (assertD1FilesExist, listD1SqliteFiles)
to verify SQLite files on disk
- Create shared vitest setup file (setup.ts) with vi.stubEnv, D1 pool
init, and common beforeEach/afterEach hooks
- Add helpers.ts with D1Pool management, adapter factories, and query
verification utilities
- Update GitHub Actions to pass RUNNER_TEMP for wrangler persistence path
- All 184 tests pass against real SQLite-backed D1 instances
https://claude.ai/code/session_013ggvpkaVD7QivK8XaS4YMB
This reverts commit 7f4ecac.
Add support for 'feat/d1-multi-tenancy' branch in test workflow
Removed environment variable RUNNER_TEMP from sharding scenarios.
- Add per-scenario test scripts (test:sharding, test:integration, etc.) to package.json - Add concurrency group with cancel-in-progress to all 8 workflow files https://claude.ai/code/session_013ggvpkaVD7QivK8XaS4YMB
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.
Continuing work on #17