Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 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
163 changes: 163 additions & 0 deletions docs/commands/database.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
---
title: Netlify CLI database command
description: Provision a production ready Postgres database with a single command
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟑 Minor

Hyphenate β€œproduction-ready” in command description text.

Use production-ready (compound adjective) instead of production ready in both the frontmatter description and generated command description text.

✏️ Proposed wording tweak
-description: Provision a production ready Postgres database with a single command
+description: Provision a production-ready Postgres database with a single command
-Provision a production ready Postgres database with a single command
+Provision a production-ready Postgres database with a single command

Also applies to: 12-12

πŸ€– Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/commands/database.md` at line 3, Update the frontmatter and any
generated command description text to hyphenate the compound adjective: change
the value for the frontmatter key "description" from "production ready" to
"production-ready" and replace any other occurrences of the exact phrase
"production ready" in the generated command description output (search for
"production ready" in the file and related generation/template code) so the
command description consistently reads "production-ready".

sidebar:
label: database
---

# `database`


<!-- AUTO-GENERATED-CONTENT:START (GENERATE_COMMANDS_DOCS) -->
Provision a production ready Postgres database with a single command

**Usage**

```bash
netlify database
```

**Flags**

- `filter` (*string*) - For monorepos, specify the name of the application to run the command in
- `debug` (*boolean*) - Print debugging information
- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in

| Subcommand | description |

Check warning on line 26 in docs/commands/database.md

View workflow job for this annotation

GitHub Actions / lint-docs

[vale] reported by reviewdog 🐢 [base.spelling] Spellcheck: did you really mean 'Subcommand'? Raw Output: {"message": "[base.spelling] Spellcheck: did you really mean 'Subcommand'?", "location": {"path": "docs/commands/database.md", "range": {"start": {"line": 26, "column": 3}}}, "severity": "WARNING"}
|:--------------------------- |:-----|
| [`status`](/commands/database#status) | Check the status of the database, including applied and pending migrations |
| [`init`](/commands/database#init) | Interactive setup: install the package, scaffold a starter migration, and verify the database |
| [`connect`](/commands/database#connect) | Connect to the database |
| [`reset`](/commands/database#reset) | Reset the local development database, removing all data and tables |
| [`migrations`](/commands/database#migrations) | Manage database migrations |


**Examples**

```bash
netlify database status
netlify database migrations apply
netlify database migrations pull
netlify database migrations new
netlify database reset
```

---
## `status`

Check the status of the database, including applied and pending migrations

**Usage**

```bash
netlify status
```
Comment thread
coderabbitai[bot] marked this conversation as resolved.

**Flags**

- `branch` (*string*) - Netlify branch name to query; defaults to the local development database
- `json` (*boolean*) - Output result as JSON
- `show-credentials` (*boolean*) - Include the full connection string (including username and password) in the output
- `debug` (*boolean*) - Print debugging information
- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in

**Examples**

```bash
netlify database status
netlify database status --show-credentials
netlify database status --json
netlify database status --branch my-feature-branch
```

---
## `init`

Interactive setup: install the package, scaffold a starter migration, and verify the database

**Usage**

```bash
netlify init
```

**Flags**

- `filter` (*string*) - For monorepos, specify the name of the application to run the command in
- `yes` (*boolean*) - Non-interactive mode. Accepts the defaults for every prompt.
- `debug` (*boolean*) - Print debugging information
- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in

**Examples**

```bash
netlify database init
netlify database init --yes
```

---
## `connect`

Connect to the database

**Usage**

```bash
netlify connect
```

**Flags**

- `filter` (*string*) - For monorepos, specify the name of the application to run the command in
- `json` (*boolean*) - Output query results as JSON. When used without --query, prints the connection details as JSON instead.
- `query` (*string*) - Execute a single query and exit
- `debug` (*boolean*) - Print debugging information
- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in

**Examples**

```bash
netlify database connect
netlify database connect --query "SELECT * FROM users"
netlify database connect --json --query "SELECT * FROM users"
netlify database connect --json
```

---
## `reset`

Reset the local development database, removing all data and tables

**Usage**

```bash
netlify reset
```

**Flags**

- `filter` (*string*) - For monorepos, specify the name of the application to run the command in
- `json` (*boolean*) - Output result as JSON
- `debug` (*boolean*) - Print debugging information
- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in

---
## `migrations`

Manage database migrations

**Usage**

```bash
netlify migrations
```

**Flags**

- `filter` (*string*) - For monorepos, specify the name of the application to run the command in
- `debug` (*boolean*) - Print debugging information
- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in

---

<!-- AUTO-GENERATED-CONTENT:END -->
86 changes: 0 additions & 86 deletions docs/commands/db.md

This file was deleted.

9 changes: 6 additions & 3 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,17 @@ Generate shell completion script

Create a new Netlify project using an AI agent

### [db](/commands/db)
### [database](/commands/database)

Provision a production ready Postgres database with a single command

| Subcommand | description |
|:--------------------------- |:-----|
| [`init`](/commands/db#init) | Initialize a new database for the current site |
| [`status`](/commands/db#status) | Check the status of the database |
| [`status`](/commands/database#status) | Check the status of the database, including applied and pending migrations |
| [`init`](/commands/database#init) | Interactive setup: install the package, scaffold a starter migration, and verify the database |
| [`connect`](/commands/database#connect) | Connect to the database |
| [`reset`](/commands/database#reset) | Reset the local development database, removing all data and tables |
| [`migrations`](/commands/database#migrations) | Manage database migrations |


### [deploy](/commands/deploy)
Expand Down
42 changes: 42 additions & 0 deletions e2e/install.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ beforeAll(async () => {
},
},
packages: {
'@netlify/*': {
access: '$all',
publish: '$all',
proxy: 'npmjs',
},
'@*/*': {
access: '$all',
publish: 'noone',
Expand Down Expand Up @@ -139,6 +144,43 @@ beforeAll(async () => {
path.join(publishWorkspace, '.npmrc'),
`//${registryURL.hostname}:${registryURL.port}/:_authToken=dummy`,
)

// Replace `file:*.tgz` deps (used for testing unreleased local builds) with their real version
// and publish each tarball to Verdaccio so the published netlify-cli resolves them via the registry.
const publishPkgPath = path.join(publishWorkspace, 'package.json')
const publishPkg = JSON.parse(await fs.readFile(publishPkgPath, 'utf8')) as {
dependencies?: Record<string, string>
devDependencies?: Record<string, string>
}
const depBuckets = [publishPkg.dependencies, publishPkg.devDependencies].filter(
(bucket): bucket is Record<string, string> => bucket != null,
)
for (const bucket of depBuckets) {
for (const [name, spec] of Object.entries(bucket)) {
const match = /^file:(.+\.tgz)$/.exec(spec)
if (!match) continue
const tgzPath = path.resolve(publishWorkspace, match[1])
const { stdout: innerManifestJSON } = await execa('tar', ['-xzOf', tgzPath, 'package/package.json'])
const innerManifest = JSON.parse(innerManifestJSON) as { name: string; version: string }
if (innerManifest.name !== name) {
throw new Error(
`Tarball ${tgzPath} contains package "${innerManifest.name}" but is referenced as "${name}" in package.json`,
)
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
const publishResult = await execa(
'npm',
['publish', tgzPath, `--registry=${registryURL.toString()}`, '--access=public', '--tag=testing'],
{ cwd: publishWorkspace, all: true, reject: false },
)
if (publishResult.exitCode !== 0) {
const detail = publishResult.all ? `:\n\n${publishResult.all}` : ''
throw new Error(`Failed to publish ${name}@${innerManifest.version} from ${tgzPath}${detail}`)
}
bucket[name] = innerManifest.version
}
}
await fs.writeFile(publishPkgPath, `${JSON.stringify(publishPkg, null, 2)}\n`)

await execa('npm', ['publish', `--registry=${registryURL.toString()}`, '--tag=testing'], {
cwd: publishWorkspace,
stdio: debug.enabled ? 'inherit' : 'ignore',
Expand Down
Binary file added netlify-dev-4.17.4-unflag-database.1.tgz
Binary file not shown.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"@netlify/build": "35.13.3",
"@netlify/build-info": "10.5.1",
"@netlify/config": "24.5.0",
"@netlify/dev": "4.17.3",
"@netlify/dev": "file:netlify-dev-4.17.4-unflag-database.1.tgz",
"@netlify/dev-utils": "4.4.3",
"@netlify/edge-bundler": "14.10.1",
"@netlify/edge-functions": "3.0.6",
Expand Down
6 changes: 6 additions & 0 deletions site/netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,9 @@
to = "https://github.com/netlify/netlifyctl/archive/v0.4.0.tar.gz"
status = 302
force = false
[[redirects]]
# Old database command
from = "/commands/db/"
to = "/commands/database/"
status = 301
force = false
Loading
Loading