-
Notifications
You must be signed in to change notification settings - Fork 3.2k
feat: adds new Cloudflare D1 SQLite adapter, R2 storage adapter and Cloudflare template #12537
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 36 commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
6652608
move sqlite logic to the drizzle package
r1tsuu f51c972
add exports from drizzle
r1tsuu 0829cfb
fix imports
r1tsuu 52f9dca
finish d1 package and fix errors
r1tsuu da4270f
sqlOnly migrations
r1tsuu 9bd5f6f
try testing
r1tsuu 733594b
fix package jason
r1tsuu 5de2f52
fix vercel postgres build
r1tsuu fd850e7
fix postgres build
r1tsuu c3af32e
fix postgres build 2
r1tsuu be4f11c
Merge branch 'main' of github.com:payloadcms/payload into feat/add-d1…
r1tsuu 9ce07c7
fix type
r1tsuu 8595b57
fix type
r1tsuu 3d57b06
Merge branch 'main' of github.com:payloadcms/payload into feat/add-d1…
r1tsuu 65b110e
fix type
r1tsuu 3f09e27
execute method
r1tsuu 9201051
storage r2
r1tsuu 72fbcc3
Merge branch 'main' of github.com:payloadcms/payload into feat/add-d1…
r1tsuu 759bb98
change version
r1tsuu fb19606
delete :memory
r1tsuu f87db1c
add r2 and d1 to publishList in script
paulpopus ca62628
empty commit for new hash
paulpopus f95bba4
Merge branch 'main' of github.com:payloadcms/payload into feat/add-d1…
r1tsuu 3291d84
add sqlite to test package json
r1tsuu df9fce5
changes to d1 package
paulpopus 8916aea
remove sqlOnly
paulpopus b88cbd7
remove miniflare/d1 dep as its deprecated
paulpopus 8775d75
commit lock file
paulpopus 224d7a2
update package.json for adapter
paulpopus 618a991
add template
paulpopus 642d1a0
update pack all to dest
paulpopus 4154be2
update lock file
paulpopus d2a3f22
add to setupProd
paulpopus 7dcf69e
remove as any
paulpopus bc94fac
add docs and updated readme
paulpopus 3ea6ede
add link to issue
paulpopus 91eaf61
update docs with beta warning and readme
paulpopus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| /migrations |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| .tmp | ||
| **/.git | ||
| **/.hg | ||
| **/.pnp.* | ||
| **/.svn | ||
| **/.yarn/** | ||
| **/build | ||
| **/dist/** | ||
| **/node_modules | ||
| **/temp |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| { | ||
| "$schema": "https://json.schemastore.org/swcrc", | ||
| "sourceMaps": true, | ||
| "jsc": { | ||
| "target": "esnext", | ||
| "parser": { | ||
| "syntax": "typescript", | ||
| "tsx": true, | ||
| "dts": true | ||
| } | ||
| }, | ||
| "module": { | ||
| "type": "es6" | ||
| } | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| MIT License | ||
|
|
||
| Copyright (c) 2018-2025 Payload CMS, Inc. <[email protected]> | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining | ||
| a copy of this software and associated documentation files (the | ||
| 'Software'), to deal in the Software without restriction, including | ||
| without limitation the rights to use, copy, modify, merge, publish, | ||
| distribute, sublicense, and/or sell copies of the Software, and to | ||
| permit persons to whom the Software is furnished to do so, subject to | ||
| the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be | ||
| included in all copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, | ||
| EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
| MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
| IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
| CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
| TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
| SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| # Payload SQLite Adapter | ||
paulpopus marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| Official SQLite adapter for [Payload](https://payloadcms.com). | ||
|
|
||
| - [Main Repository](https://github.com/payloadcms/payload) | ||
| - [Payload Docs](https://payloadcms.com/docs) | ||
|
|
||
| ## Installation | ||
|
|
||
| ```bash | ||
| npm install @payloadcms/db-sqlite | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| ```ts | ||
| import { buildConfig } from 'payload/config' | ||
| import { sqliteAdapter } from '@payloadcms/db-sqlite' | ||
|
|
||
| export default buildConfig({ | ||
| db: sqliteAdapter({ | ||
| client: { | ||
| url: process.env.DATABASE_URI, | ||
| }, | ||
| }), | ||
| // ...rest of config | ||
| }) | ||
| ``` | ||
|
|
||
| More detailed usage can be found in the [Payload Docs](https://payloadcms.com/docs/configuration/overview). | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| import * as esbuild from 'esbuild' | ||
| import fs from 'fs' | ||
| import path from 'path' | ||
| import { fileURLToPath } from 'url' | ||
| const filename = fileURLToPath(import.meta.url) | ||
| const dirname = path.dirname(filename) | ||
| import { commonjs } from '@hyrious/esbuild-plugin-commonjs' | ||
|
|
||
| async function build() { | ||
| const resultServer = await esbuild.build({ | ||
| entryPoints: ['src/index.ts'], | ||
| bundle: true, | ||
| platform: 'node', | ||
| format: 'esm', | ||
| outfile: 'dist/index.js', | ||
| splitting: false, | ||
| external: [ | ||
| '*.scss', | ||
| '*.css', | ||
| 'drizzle-kit', | ||
| 'libsql', | ||
| 'pg', | ||
| '@payloadcms/translations', | ||
| '@payloadcms/drizzle', | ||
| 'payload', | ||
| 'payload/*', | ||
| ], | ||
| minify: true, | ||
| metafile: true, | ||
| tsconfig: path.resolve(dirname, './tsconfig.json'), | ||
| plugins: [commonjs()], | ||
| sourcemap: true, | ||
| }) | ||
| console.log('db-sqlite bundled successfully') | ||
|
|
||
| fs.writeFileSync('meta_server.json', JSON.stringify(resultServer.metafile)) | ||
| } | ||
| await build() |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,134 @@ | ||
| { | ||
| "name": "@payloadcms/db-d1-sqlite", | ||
| "version": "3.57.0", | ||
| "description": "The officially supported D1 SQLite database adapter for Payload", | ||
| "homepage": "https://payloadcms.com", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/payloadcms/payload.git", | ||
| "directory": "packages/db-d1-sqlite" | ||
| }, | ||
| "license": "MIT", | ||
| "author": "Payload <[email protected]> (https://payloadcms.com)", | ||
| "maintainers": [ | ||
| { | ||
| "name": "Payload", | ||
| "email": "[email protected]", | ||
| "url": "https://payloadcms.com" | ||
| } | ||
| ], | ||
| "type": "module", | ||
| "exports": { | ||
| ".": { | ||
| "import": "./src/index.ts", | ||
| "require": "./src/index.ts", | ||
| "types": "./src/index.ts" | ||
| }, | ||
| "./types": { | ||
| "import": "./src/exports/types-deprecated.ts", | ||
| "require": "./src/exports/types-deprecated.ts", | ||
| "types": "./src/exports/types-deprecated.ts" | ||
| }, | ||
| "./migration-utils": { | ||
| "import": "./src/exports/migration-utils.ts", | ||
| "require": "./src/exports/migration-utils.ts", | ||
| "types": "./src/exports/migration-utils.ts" | ||
| }, | ||
| "./drizzle": { | ||
| "import": "./src/drizzle-proxy/index.ts", | ||
| "types": "./src/drizzle-proxy/index.ts", | ||
| "default": "./src/drizzle-proxy/index.ts" | ||
| }, | ||
| "./drizzle/sqlite-core": { | ||
| "import": "./src/drizzle-proxy/sqlite-core.ts", | ||
| "types": "./src/drizzle-proxy/sqlite-core.ts", | ||
| "default": "./src/drizzle-proxy/sqlite-core.ts" | ||
| }, | ||
| "./drizzle/d1": { | ||
| "import": "./src/drizzle-proxy/d1.ts", | ||
| "types": "./src/drizzle-proxy/d1.ts", | ||
| "default": "./src/drizzle-proxy/d1.ts" | ||
| }, | ||
| "./drizzle/relations": { | ||
| "import": "./src/drizzle-proxy/relations.ts", | ||
| "types": "./src/drizzle-proxy/relations.ts", | ||
| "default": "./src/drizzle-proxy/relations.ts" | ||
| } | ||
| }, | ||
| "main": "./src/index.ts", | ||
| "types": "./src/index.ts", | ||
| "files": [ | ||
| "dist", | ||
| "mock.js" | ||
| ], | ||
| "scripts": { | ||
| "build": "pnpm build:swc && pnpm build:types", | ||
| "build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths", | ||
| "build:types": "tsc --emitDeclarationOnly --outDir dist", | ||
| "clean": "rimraf -g {dist,*.tsbuildinfo}", | ||
| "lint": "eslint .", | ||
| "lint:fix": "eslint . --fix", | ||
| "prepack": "pnpm clean && pnpm turbo build", | ||
| "prepublishOnly": "pnpm clean && pnpm turbo build" | ||
| }, | ||
| "dependencies": { | ||
| "@payloadcms/drizzle": "workspace:*", | ||
| "console-table-printer": "2.12.1", | ||
| "drizzle-kit": "0.31.4", | ||
| "drizzle-orm": "0.44.2", | ||
| "prompts": "2.4.2", | ||
| "to-snake-case": "1.0.0", | ||
| "uuid": "9.0.0" | ||
| }, | ||
| "devDependencies": { | ||
| "@payloadcms/eslint-config": "workspace:*", | ||
| "@types/pg": "8.10.2", | ||
| "@types/to-snake-case": "1.0.0", | ||
| "@types/uuid": "10.0.0", | ||
| "payload": "workspace:*" | ||
| }, | ||
| "peerDependencies": { | ||
| "payload": "workspace:*" | ||
| }, | ||
| "publishConfig": { | ||
| "exports": { | ||
| ".": { | ||
| "import": "./dist/index.js", | ||
| "require": "./dist/index.js", | ||
| "types": "./dist/index.d.ts" | ||
| }, | ||
| "./types": { | ||
| "import": "./dist/exports/types-deprecated.js", | ||
| "require": "./dist/exports/types-deprecated.js", | ||
| "types": "./dist/exports/types-deprecated.d.ts" | ||
| }, | ||
| "./migration-utils": { | ||
| "import": "./dist/exports/migration-utils.js", | ||
| "require": "./dist/exports/migration-utils.js", | ||
| "types": "./dist/exports/migration-utils.d.ts" | ||
| }, | ||
| "./drizzle": { | ||
| "import": "./dist/drizzle-proxy/index.js", | ||
| "types": "./dist/drizzle-proxy/index.d.ts", | ||
| "default": "./dist/drizzle-proxy/index.js" | ||
| }, | ||
| "./drizzle/sqlite-core": { | ||
| "import": "./dist/drizzle-proxy/sqlite-core.js", | ||
| "types": "./dist/drizzle-proxy/sqlite-core.d.ts", | ||
| "default": "./dist/drizzle-proxy/sqlite-core.js" | ||
| }, | ||
| "./drizzle/d1": { | ||
| "import": "./dist/drizzle-proxy/d1.js", | ||
| "types": "./dist/drizzle-proxy/d1.d.ts", | ||
| "default": "./dist/drizzle-proxy/d1.js" | ||
| }, | ||
| "./drizzle/relations": { | ||
| "import": "./dist/drizzle-proxy/relations.js", | ||
| "types": "./dist/drizzle-proxy/relations.d.ts", | ||
| "default": "./dist/drizzle-proxy/relations.js" | ||
| } | ||
| }, | ||
| "main": "./dist/index.js", | ||
| "types": "./dist/index.d.ts" | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.