Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .changeset/common-pears-drive.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
'@astrojs/mdx': major
'@astrojs/vue': major
'astro': major
'@astrojs/db': major
---

Upgrade to Vite v8
1 change: 0 additions & 1 deletion .changeset/pre.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"@astrojs/prism": "4.0.1",
"@astrojs/rss": "4.0.17",
"create-astro": "5.0.3",
"@astrojs/db": "0.20.1",
"@astrojs/alpinejs": "0.5.0",
"@astrojs/cloudflare": "13.1.3",
"@astrojs/markdoc": "1.0.2",
Expand Down
7 changes: 7 additions & 0 deletions .changeset/remove-db-cli-command.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'astro': major
---

Removes the `astro db`, `astro login`, `astro logout`, `astro link`, and `astro init` CLI commands.

The `@astrojs/db` package is now deprecated. We recommend using a database client (Drizzle, Kysely, etc.) directly instead.
Comment on lines +5 to +7

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd say first that @astrojs/db is removed: the CLI commands are only a consequence. When scanning, people might pay more attention to the first line.

And because this is a breaking change that can affect a lot of people, I would have been a bit more verbose to bring attention this is something big.

Something like:

Suggested change
Removes the `astro db`, `astro login`, `astro logout`, `astro link`, and `astro init` CLI commands.
The `@astrojs/db` package is now deprecated. We recommend using a database client (Drizzle, Kysely, etc.) directly instead.
Removes the `@astrojs/db` package as it is no longer maintained.
The `@astrojs/db` package were deprecated in v6.4.5 and is now removed. This means the `astro db`, `astro login`, `astro logout`, `astro link`, and `astro init` CLI commands have also been removed.
I you were using Astro DB in your project, remove `@astrojs/db` from your project's dependencies and replace it with one of the following alternatives:
- **Node.js built-in SQLite**: Node.js now includes a built-in [`node:sqlite`](https://nodejs.org/api/sqlite.html) module (available since Node.js v22.5.0). This is a good option if you are using the Node.js adapter and were using `@astrojs/db` for local SQLite storage.
- **[Drizzle ORM](https://orm.drizzle.team/)**: If you were using `@astrojs/db` for its Drizzle-based schema and query API, you can use Drizzle directly with any supported database.
- **Other database libraries**: Use any database library that suits your deployment platform (e.g. [Turso](https://turso.tech/), [PlanetScale](https://planetscale.com/), [Neon](https://neon.tech/)).

6 changes: 0 additions & 6 deletions .github/renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,6 @@
//#endregion

//#region Standalone packages
{
"groupName": "@astrojs/db",
"matchManagers": ["npm"],
"matchUpdateTypes": ["minor", "patch"],
"matchFileNames": ["packages/db/**"]
},
{
"groupName": "create-astro",
"matchManagers": ["npm"],
Expand Down
3 changes: 0 additions & 3 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ benchmark/results/
**/.vercel
**/.vscode-test

# Short-term need to format
!packages/db/test/fixtures

# Directories
.github
.changeset
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ Join us on [Discord](https://astro.build/chat) to meet other maintainers. We'll
| [@astrojs/sitemap](packages/integrations/sitemap) | [![@astrojs/sitemap version](https://img.shields.io/npm/v/@astrojs/sitemap.svg?label=%20)](packages/integrations/sitemap/CHANGELOG.md) |
| [@astrojs/alpinejs](packages/integrations/alpinejs) | [![@astrojs/alpinejs version](https://img.shields.io/npm/v/@astrojs/alpinejs.svg?label=%20)](packages/integrations/alpinejs/CHANGELOG.md) |
| [@astrojs/mdx](packages/integrations/mdx) | [![@astrojs/mdx version](https://img.shields.io/npm/v/@astrojs/mdx.svg?label=%20)](packages/integrations/mdx/CHANGELOG.md) |
| [@astrojs/db](packages/db) | [![@astrojs/db version](https://img.shields.io/npm/v/@astrojs/db.svg?label=%20)](packages/db/CHANGELOG.md) |
| [@astrojs/rss](packages/astro-rss) | [![@astrojs/rss version](https://img.shields.io/npm/v/@astrojs/rss.svg?label=%20)](packages/astro-rss/CHANGELOG.md) |
| [@astrojs/netlify](packages/integrations/netlify) | [![@astrojs/netlify version](https://img.shields.io/npm/v/@astrojs/netlify.svg?label=%20)](packages/integrations/netlify/CHANGELOG.md) |
| [@astrojs/check](packages/language-tools/astro-check) | [![astro-check version](https://img.shields.io/npm/v/@astrojs/check.svg?label=%20)](packages/language-tools/astro-check/CHANGELOG.md) |
Expand Down
1 change: 0 additions & 1 deletion biome.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@
},
{
"includes": [
"**/packages/db/**/cli/**/*.ts",
"**/benchmark/**/*.js",
"**/packages/astro/src/cli/**/*.ts",
"**/packages/astro/bin/**/*.mjs"
Expand Down
18 changes: 0 additions & 18 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,24 +140,6 @@ const configs = [
},
},

{
files: ['packages/db/src/runtime/**/*.ts'],
rules: {
'no-restricted-imports': 'off',
'@typescript-eslint/no-restricted-imports': [
'error',
{
patterns: [
{
group: ['../core/*'],
allowTypeImports: true,
},
],
},
],
},
},

{
files: [
'packages/language-tools/ts-plugin/**/*',
Expand Down
3 changes: 0 additions & 3 deletions knip.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ export default {
entry: [srcEntry, dtsEntry, testEntry],
ignoreUnresolved: ['#prism-loadLanguages'],
},
'packages/db': {
entry: [srcEntry, dtsEntry, testEntry, 'test/types/**/*'],
},
'packages/integrations/*': {
entry: [srcEntry, dtsEntry, testEntry],
},
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
"@flue/runtime": "^0.8.0",
"@types/node": "^22.10.6",
"bgproc": "^0.2.0",
"esbuild": "0.25.5",

@ocavue ocavue Jun 9, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

packages/db imported esbuild without declaring it in its own package.json, so it relied on the hoisted root esbuild@0.25.5. Now that db is gone, root esbuild is genuinely unused.

"eslint": "^10.4.0",
"eslint-plugin-regexp": "^3.1.0",
"knip": "5.82.1",
Expand Down
7 changes: 4 additions & 3 deletions packages/astro/e2e/actions-blog.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { rmSync } from 'node:fs';
import { expect } from '@playwright/test';
import { type DevServer, testFactory, waitForHydrate } from './test-utils.ts';

Expand All @@ -13,9 +14,9 @@ test.afterAll(async () => {
await devServer.stop();
});

test.afterEach(async ({ astro }) => {
// Force database reset between tests
await astro.editFile('./db/seed.ts', (original) => original, false);
test.afterEach(({ astro }) => {
// Reset the store between tests by deleting its data file
rmSync(new URL('src/db/temp', astro.config.root), { recursive: true, force: true });
});

test.describe('Astro Actions - Blog', () => {
Expand Down
7 changes: 4 additions & 3 deletions packages/astro/e2e/actions-react-19.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { rmSync } from 'node:fs';
import { expect } from '@playwright/test';
import { type DevServer, testFactory, waitForHydrate } from './test-utils.ts';

Expand All @@ -9,9 +10,9 @@ test.beforeAll(async ({ astro }) => {
devServer = await astro.startDevServer();
});

test.afterEach(async ({ astro }) => {
// Force database reset between tests
await astro.editFile('./db/seed.ts', (original) => original, false);
test.afterEach(({ astro }) => {
// Reset the store between tests by deleting its data file
rmSync(new URL('src/db/temp', astro.config.root), { recursive: true, force: true });
});

test.afterAll(async () => {
Expand Down
3 changes: 1 addition & 2 deletions packages/astro/e2e/fixtures/actions-blog/astro.config.mjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { defineConfig } from 'astro/config';
import db from '@astrojs/db';
import react from '@astrojs/react';
import node from '@astrojs/node';

// https://astro.build/config
export default defineConfig({
site: 'https://example.com',
integrations: [db(), react()],
integrations: [react()],
output: 'server',
adapter: node({
mode: 'standalone',
Expand Down
21 changes: 0 additions & 21 deletions packages/astro/e2e/fixtures/actions-blog/db/config.ts

This file was deleted.

15 changes: 0 additions & 15 deletions packages/astro/e2e/fixtures/actions-blog/db/seed.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/astro/e2e/fixtures/actions-blog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
},
"dependencies": {
"@astrojs/check": "workspace:*",
"@astrojs/db": "workspace:*",
"@astrojs/node": "workspace:*",
"@astrojs/react": "workspace:*",
"@types/react": "^18.3.28",
Expand Down
24 changes: 3 additions & 21 deletions packages/astro/e2e/fixtures/actions-blog/src/actions/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { db, Comment, Likes, eq, sql } from 'astro:db';
import { ActionError, defineAction } from 'astro:actions';
import { z } from 'astro/zod';
import { getCollection } from 'astro:content';
import { addComment, incrementLikes } from '../db/store';

export const server = {
logout: defineAction({
Expand All @@ -15,16 +15,7 @@ export const server = {
handler: async ({ postId }) => {
await new Promise((r) => setTimeout(r, 500));

const result = await db
.update(Likes)
.set({
likes: sql`${Likes.likes} + 1`,
})
.where(eq(Likes.postId, postId))
.returning()
.get();

return result?.likes;
return incrementLikes(postId);
},
}),

Expand All @@ -43,16 +34,7 @@ export const server = {
});
}

const comment = await db
.insert(Comment)
.values({
postId,
body,
author,
})
.returning()
.get();
return comment;
return addComment({ postId, author, body });
},
}),

Expand Down
56 changes: 56 additions & 0 deletions packages/astro/e2e/fixtures/actions-blog/src/db/store.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Tiny file-backed store for the demo actions. State is read from and written to a
// JSON file on disk, so it is shared across every module instance the dev server
// evaluates (the page render and the action handler run in separate module graphs),
// the same way the previous SQLite-backed store was. The e2e tests reset it between
// runs by deleting `./temp/` (see the `afterEach` in actions-blog.test.ts).
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';

export interface Comment {
postId: string;
author: string;
body: string;
}

interface Data {
likes: Record<string, number>;
comments: Comment[];
}

const file = new URL('./temp/store.json', import.meta.url);

function read(): Data {
if (!existsSync(file)) {
return {
likes: { 'first-post': 10 },
comments: [{ postId: 'first-post', author: 'Alice', body: 'Great post!' }],
};
}
return JSON.parse(readFileSync(file, 'utf-8'));
}

function write(data: Data): void {
mkdirSync(new URL('./temp/', import.meta.url), { recursive: true });
writeFileSync(file, JSON.stringify(data));
}

export function getLikes(postId: string): number {
return read().likes[postId] ?? 0;
}

export function incrementLikes(postId: string): number {
const data = read();
data.likes[postId] = (data.likes[postId] ?? 0) + 1;
write(data);
return data.likes[postId];
}

export function getComments(postId: string): Comment[] {
return read().comments.filter((comment) => comment.postId === postId);
}

export function addComment(comment: Comment): Comment {
const data = read();
data.comments.push(comment);
write(data);
return comment;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { type CollectionEntry, getEntry, render } from 'astro:content';
import BlogPost from '../../layouts/BlogPost.astro';
import { Logout } from '../../components/Logout';
import { db, eq, Comment, Likes } from 'astro:db';
import { getComments, getLikes } from '../../db/store';
import { Like } from '../../components/Like';
import { PostComment } from '../../components/PostComment';
import { actions } from 'astro:actions';
Expand All @@ -19,16 +19,16 @@ if (Astro.url.searchParams.has('like')) {

const comment = Astro.getActionResult(actions.blog.comment);

const comments = await db.select().from(Comment).where(eq(Comment.postId, post.id));
const comments = getComments(post.id);

const initialLikes = await db.select().from(Likes).where(eq(Likes.postId, post.id)).get();
const initialLikes = getLikes(post.id);

// Used to force validation errors for testing
const commentPostIdOverride = Astro.url.searchParams.get('commentPostIdOverride');
---

<BlogPost {...post.data}>
<Like postId={post.id} initial={initialLikes?.likes ?? 0} client:load />
<Like postId={post.id} initial={initialLikes} client:load />

<Logout client:load />

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { defineConfig } from 'astro/config';
import db from '@astrojs/db';
import react from '@astrojs/react';
import node from '@astrojs/node';

// https://astro.build/config
export default defineConfig({
site: 'https://example.com',
integrations: [db(), react()],
integrations: [react()],
output: 'static',
adapter: node({
mode: 'standalone',
Expand Down
21 changes: 0 additions & 21 deletions packages/astro/e2e/fixtures/actions-react-19/db/config.ts

This file was deleted.

15 changes: 0 additions & 15 deletions packages/astro/e2e/fixtures/actions-react-19/db/seed.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/astro/e2e/fixtures/actions-react-19/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
},
"dependencies": {
"@astrojs/check": "workspace:*",
"@astrojs/db": "workspace:*",
"@astrojs/node": "workspace:*",
"@astrojs/react": "workspace:*",
"@types/react": "npm:types-react",
Expand Down
Loading
Loading