You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit ca785ab
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: README.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,7 +36,7 @@ Read the [Void documentation](https://void.cloud) online or use the Markdown gui
36
36
37
37
`void init` adds a minimal `AGENTS.md` in new projects and asks before changing instructions in existing projects. It also links bundled skills for detected coding agents.
38
38
39
-
-[Server routes](https://void.cloud/guide/server-routing) and [pages](https://void.cloud/guide/pages-routing/overview)
39
+
-[Server routes](https://void.cloud/guide/server-routing), [pages](https://void.cloud/guide/pages-routing/overview), and [error components](https://void.cloud/guide/pages-routing/errors)
40
40
-[Database](https://void.cloud/guide/database) and [type safety](https://void.cloud/guide/type-safety)
-`requireAuth(c)` returns the authenticated user or throws `401`
121
+
-[`getAuth(c)`](../reference/api/auth.md#getauth-c) returns the request's Better Auth instance, with plugin APIs inferred from `auth.ts`, for use with Better Auth helpers.
121
122
122
123
Import `AuthUser` and `AuthSession` from `void/auth` for type annotations. They include the fields your Better Auth plugins and `user.additionalFields` add, such as `role` from `admin()`. See their fields in the [API reference](../reference/api/auth.md#authuser).
Copy file name to clipboardExpand all lines: docs/guide/database.md
+33Lines changed: 33 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -385,6 +385,39 @@ npm install arktype
385
385
386
386
See the [CLI reference](../reference/cli/database.md#database) for connection setup, SQL execution, Studio, exports, and other commands.
387
387
388
+
## Adopt an existing Drizzle PostgreSQL database {#adopt-existing-drizzle}
389
+
390
+
You can keep a PostgreSQL database that Drizzle has already migrated. Void tracks applied files separately, so record the existing history before the first Void deployment.
391
+
392
+
1. Back up the database and pause deployments. Try the procedure on a restored copy first.
393
+
2. Set `database: 'pg'` in `void.config.ts`. Keep your existing schema, SQL filenames, and `db/migrations/meta/` directory. Do not regenerate or rename migrations during adoption.
394
+
3. Check the database's Drizzle history against `meta/_journal.json` and your SQL files. Match each applied row's `created_at` to the journal entry's `when`, and its `hash` to the SHA-256 of the corresponding SQL file. Drizzle normally stores this history in `drizzle.__drizzle_migrations`; use your configured schema and table if different. If a file cannot be verified, resolve the discrepancy before continuing.
395
+
396
+
```sql
397
+
SELECT hash, created_at FROMdrizzle.__drizzle_migrationsORDER BY created_at;
398
+
```
399
+
400
+
4. Save the following as `adopt-void.sql`, replacing the example filenames with **only the migrations verified as already applied to this database**, including `.sql`. Leave new, unapplied files out of the list.
5. Run the file against the existing database with your PostgreSQL client, stopping on errors. Use the same database and PostgreSQL search path that Void will use. This records the verified filenames without executing their SQL or changing Drizzle's history.
417
+
6. Configure Void's connection to that database and run `void db status`. Verify that only new migrations are pending, then deploy. For direct Cloudflare deployments, provide that database's `DATABASE_URL` in the shell or CI environment running `void deploy`.
418
+
419
+
Repeat the verification and adoption separately for each database. An entry in one environment's history does not prove that another environment has applied it. Leave Drizzle's history table intact, and use Void for subsequent migrations.
Deploy compares your Drizzle schema with the snapshots in `db/migrations/meta/`. If you have SQL migrations without this metadata, running `void db generate` would create another migration for the same tables.
Copy file name to clipboardExpand all lines: docs/guide/deployment.md
+8Lines changed: 8 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,6 +35,14 @@ void db generate
35
35
36
36
Review and commit the SQL, then deploy again. Rollback does not reverse database migrations. See [Database](./database.md) for the local workflow.
37
37
38
+
When migrations run in a separate release step, or a preview shares an existing database, deploy code without applying application or authentication SQL migrations:
39
+
40
+
```sh
41
+
void deploy --skip-migrations
42
+
```
43
+
44
+
This works with both deployment destinations. Ensure the app supports the database's current schema. Migration files and schema checks still apply, and the next normal deploy applies any pending migrations. See [the deploy options](../reference/cli/deploy.md#void-deploy) and [`void db migrate`](../reference/cli/database.md#void-db-migrate) for supported ways to apply migrations separately.
45
+
38
46
For D1 on your own Cloudflare account, deploy saves a restore point before applying migrations and prints a [`void db restore`](../reference/cli/database.md#void-db-restore) command. Use it to recover from a bad migration, then fix the migration before deploying again. A restore discards writes made after that point; check that your deployed code works with the restored schema. See the command reference for the recovery steps and retention limits.
Use a whole-number literal such as `3600`. Void reads the value without running the file, so it ignores an expression such as `60 * 60` or a value re-exported from another module, and prints a warning.
65
+
64
66
Per-page values take precedence over `void.config.ts` patterns.
65
67
66
68
A page's `revalidate` export also applies to `routes/` handlers whose URLs match the page pattern. For example, if `pages/[...slug].server.ts` exports `revalidate`, Void can also cache the `GET` response of `routes/now.ts`. Void never caches paths under `/api`. To keep a route handler's response out of the cache, set `x-revalidate: 0` on it. See [Per-response TTL override](#per-response-ttl-override).
`withValidator({ body })` accepts the same upload. Nested names such as `profile[name]`, `tags[0]`, and `tags[]` are objects and arrays again. A multipart schema has to coerce the rest: booleans arrive as `'1'` or `'0'`, numbers and dates as strings, and `null` as `''`.
447
+
446
448
Pick the storage key on the server and allow only the file types you expect. See [Serving Files](../storage.md#serving-files) to send them back safely.
0 commit comments