Skip to content

Commit

Permalink
feat(migrate): docs (#374)
Browse files Browse the repository at this point in the history
Docs for xataio/client-ts#1542

Piggybacked some typofixes that I found along the way (using cspell)
  • Loading branch information
divyenduz authored Jul 30, 2024
1 parent 526ceab commit 1511c9d
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 11 deletions.
2 changes: 1 addition & 1 deletion 010-Getting-started/010-what-is-xata.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: What is Xata?
navTitle: What is Xata?
keywords: ['severless', 'data platform', 'PostgreSQL', 'architecture']
keywords: ['serverless', 'data platform', 'PostgreSQL', 'architecture']
description: An overview of Xata, the data platform for PostgreSQL.
slug: concepts/serverless-data-platform
published: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ export default defineConfig({
});
```

With `output` set to `server`, Astro can now read paramaters from the URL. Now, you are ready to add the search functionality. If you like to deploy this project later. Make sure you also add the ssr adaptor parameter `adapter: your adapter here()` as well. Follow the Astro docs for that here: [Astro docs SSR Adapters](https://docs.astro.build/en/guides/server-side-rendering/)
With `output` set to `server`, Astro can now read parameters from the URL. Now, you are ready to add the search functionality. If you like to deploy this project later. Make sure you also add the ssr adaptor parameter `adapter: your adapter here()` as well. Follow the Astro docs for that here: [Astro docs SSR Adapters](https://docs.astro.build/en/guides/server-side-rendering/)

After we added our adapter, the above code would then go as follows with the adapter added:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ When you insert data into a Xata database, it is automatically indexed for full-
any configuration to enable search, just need to use the
[TypeScript SDK search feature](/docs/sdk/search).

Aadd this functionality to `/api/posts` API server route:
Add this functionality to `/api/posts` API server route:

```tsx title="server/api/posts.ts" {5-13}
import { getXataClient } from '../../src/xata';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ export async function loader({ params }: LoaderFunctionArgs) {
```
<Alert status="warning">
In case you encounter a `"Runtime.UnhandledPromiseRejection"` when deploying the Remix app, try passing the Remix fetch implenentation to the XataClient.
In case you encounter a `"Runtime.UnhandledPromiseRejection"` when deploying the Remix app, try passing the Remix fetch implementation to the XataClient.
```ts
import { fetch as webFetch } from "@remix-run/web-fetch";
import { XataClient } from "src/xata";
Expand Down
60 changes: 59 additions & 1 deletion 020-Connect/015-CLI/010-cli.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ The Xata CLI requires credentials (in the form of an API key) to perform command
xata auth login
```

Running the above will ask if you want to authenticate using an existing API key or by creating a new key. If this is your first time using Xata, choose to create a new key. The CLI willprompt you to visit the Xata website in your browser where a key will be generated. To instead use an existing key, copy a key you previously created on the [account settings][0] page.
Running the above will ask if you want to authenticate using an existing API key or by creating a new key. If this is your first time using Xata, choose to create a new key. The CLI will prompt you to visit the Xata website in your browser where a key will be generated. To instead use an existing key, copy a key you previously created on the [account settings][0] page.

Regardless of the method you chose, Xata generates a file at `~/.config/xata/credentials` to store your API keys. It looks something like this.

Expand Down Expand Up @@ -106,6 +106,64 @@ It can run non-interactively for use in build scripts, with `XATA_API_KEY` and `
xata init --db https://workspace-1234.us-east-1.xata.sh/db/database-name --sdk --no-input --yes --codegen=src/xata.ts --force
```

### migrate

Use `xata migrate` command to execute and control [multi-schema migrations](https://xata.io/blog/multi-version-schema-migrations) with CLI. The following subcommands are available: start, complete, rollback, status, list.
The following commands use the branch name `main` as an example.

To start a new migration, use

```bash
xata migrate start main --migration-json '[{ "alter_column": { "table": "table", "column": "text", "type": "text", "up": "description", "down": "description" } }]'
```

Or

If you want to have the pgroll migration in a separate file, use

```bash
xata migrate start main migration.json
```

Learn about [pgroll](https://github.com/xataio/pgroll).
See possible [pgroll migration examples](https://github.com/xataio/pgroll/tree/main/examples).

To see the status of a running migration, use

```bash
xata migrate status main
```

To see the list of migration jobs, use

```bash
xata migrate status main
```

To complete a migration, use

```bash
xata migrate complete main
```

To rollback a migration, use

```bash
xata migrate rollback main
```

There are other options available with `xata migrate` commands, use the following to see all options

```bash
xata migrate --help
```

Or for sub-commands

```bash
xata migrate start --help
```

### codegen

The `xata codegen` command updates the Xata client and optionally creates typings for a TypeScript based project. On its initial run, the CLI generates these files in the `src/xata.ts` directory. Subsequent runs will update the file. Since this file is automated, it is important that you'd edit it directly, but rerun the `xata codegen` command periodically as you make schema updates.
Expand Down
4 changes: 2 additions & 2 deletions 020-Connect/030-Python/010-xata-sdk.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ from xata.helpers import BulkProcessor
client = XataClient()
bp = BulkProcessor(client)

# Sub to a queue and continously read messages
# Sub to a queue and continuously read messages
while queue.subscribed():
msg = queue.read()

Expand Down Expand Up @@ -760,7 +760,7 @@ changed to a more concise call in `1.x`:
lst = xata.databases().list()
```

Continously the function arguments are also converted to the pep-8 standard, lowercased and separated by an underscore, `SessionId` becomes `session_id`.
Continuously the function arguments are also converted to the pep-8 standard, lowercased and separated by an underscore, `SessionId` becomes `session_id`.

### Error Handling

Expand Down
2 changes: 1 addition & 1 deletion 020-Connect/030-Python/120-pg8000.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The [pg8000](https://pypi.org/project/pg8000/) driver comes with different API's
Both API's use the parameterized approach to define the connection parameters.
Please replace the placeholders in the connection string or parameters, as indicated on the [connect to Postgres](/docs/postgres) page.

pg8000 does not default to encrypted connections out of the box, and as Xata rejects all [not encyrpted connections](/docs/postgres#sslmode), you need to specify the SSL context.
pg8000 does not default to encrypted connections out of the box, and as Xata rejects all [not encryrpted connections](/docs/postgres#sslmode), you need to specify the SSL context.
This is done by adding the `ssl_context=True` in the connection parameters.
The following examples both demonstrate this.

Expand Down
2 changes: 1 addition & 1 deletion 050-Manage/040-pr-based-workflow.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ The GitHub integration will output errors if your migration files are out of syn

Since the `.xata/migrations` folder is simply a code-based ledger of the content we keep on the server, you can always delete the folder and rerun `xata pull my_feature` to rebuild it. Then recommit your files to GitHub and check the results.

If you've already run `xata pull` and committed it, but you are still recieving errors from our app in GitHub, try manually deleting the `preview-my_feature` database branch within the Xata UI. Your next commit to GitHub should create a new, working preview branch from your migration files.
If you've already run `xata pull` and committed it, but you are still receiving errors from our app in GitHub, try manually deleting the `preview-my_feature` database branch within the Xata UI. Your next commit to GitHub should create a new, working preview branch from your migration files.

## Limitations

Expand Down
2 changes: 1 addition & 1 deletion 070-Integrations/005-csv.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Choose a format that matches the data you're entering. Xata columns support the
| Datetime | Date and time information. Our CSV importer will attempt to parse all common datetimes | `2023-08-30T00:00:00.000Z` or `26-02-88` or any other date format |
| Link to Table | ID of a record in another table | `rec_xyz` or `usr_xyz`if using custom IDs |
| Email | Email addresses | `user@example.com` |
| Multiple | Multiple values seperated by a comma or a JSON array | `Red,Green` or `["Red", "Green"]` |
| Multiple | Multiple values separated by a comma or a JSON array | `Red,Green` or `["Red", "Green"]` |
| File | Not supported | |
| Vector | Not supported | |

Expand Down
2 changes: 1 addition & 1 deletion 070-Integrations/010-airbyte.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Airbyte with Xata
navTitle: Airbyte
keywords: ['airbyte', 'migrate data']
description: Use Xata with Airbyte, the integration platform that enables efficent data management from multiple sources
description: Use Xata with Airbyte, the integration platform that enables efficient data management from multiple sources
slug: integrations/airbyte
published: true
status: beta
Expand Down

0 comments on commit 1511c9d

Please sign in to comment.