Skip to content

Commit

Permalink
Merge branch 'main' into uwui
Browse files Browse the repository at this point in the history
  • Loading branch information
jharrell authored May 1, 2024
2 parents fdf83bc + b31909a commit 97b9008
Show file tree
Hide file tree
Showing 42 changed files with 1,128 additions and 339 deletions.
38 changes: 38 additions & 0 deletions .github/actions/create-or-update-comment/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Post Comment
description: Create or update a comment on a pull request
inputs:
pull-request:
description: The PR (number) to post in
required: true
body:
description: The comment body (will replace if comment already exists)
required: true
body-includes:
description: An optional string to search by (use this almost always)
required: false
default: 'bot'
runs:
using: composite
steps:
- name: Find existing comment
uses: peter-evans/find-comment@v3
id: find-existing
with:
issue-number: ${{ inputs.pull-request }}
comment-author: 'github-actions[bot]'
body-includes: ${{ inputs.body-includes }}

- name: Create comment
if: steps.find-existing.outputs.comment-id == ''
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ inputs.pull-request }}
body: ${{ inputs.body }}

- name: Update comment
if: steps.find-existing.outputs.comment-id != ''
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.find-existing.outputs.comment-id }}
body: ${{ inputs.body }}
edit-mode: replace
107 changes: 107 additions & 0 deletions .github/workflows/check-all-links.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
name: Check all content (MDX) links

on:
pull_request:

jobs:
check-for-absolute-urls:
name: "Check for absolute prisma.io urls"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: check for docs urls
id: absolute-urls
run: |
FILES_WITH_ABS_URLS=$(grep -Erl "https://prisma\.io/docs|https://www\.prisma\.io/docs" content) || echo "no absolute URLs found."
OUTPUT="## Absolute URL check"$'\n'
SUCCESS=false
if [ -n "${FILES_WITH_ABS_URLS}" ]; then # if there were matching files
OUTPUT+="The following files have absolute URLs to prisma.io/docs. Please replace them with relative URLs."$'\n'
OUTPUT+="Example: https://www.prisma.io/docs/getting-started/quickstart -> /getting-started/quickstart"$'\n'
for line in ${FILES_WITH_ABS_URLS}
do
OUTPUT+="${line}"$'\n'
done
else
# no matching files
OUTPUT+="No absolute URLs to prisma.io/docs found."
SUCCESS=true
fi
# https://github.com/orgs/community/discussions/26288#discussioncomment-3876281
{
echo 'body<<EOF'
echo "$OUTPUT"
echo EOF
} >> "$GITHUB_OUTPUT"
echo "success=${SUCCESS}" >> "$GITHUB_OUTPUT"
- uses: ./.github/actions/create-or-update-comment
with:
pull-request: ${{ github.event.pull_request.number }}
body: ${{ steps.absolute-urls.outputs.body }}
body-includes: absolute URLs

- name: report success
run: |
if ${{ steps.absolute-urls.outputs.success }}; then
exit 0;
else
exit 1;
fi
check-for-dead-external-links:
name: Check external links
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18

- name: Install deps
run: npm install

- name: Install remark presets
run: npm install remark-lint-no-dead-urls

- name: run remark-cli
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
run: |
npx remark-cli . -qf -e=md,mdx --use=remark-mdx --use remark-frontmatter --use remark-gfm \
--use "remark-lint-no-dead-urls=skipLocalhost:true,skipUrlPatterns:['https://www.notion.so/prismaio','https://www.prisma.io/docs','https://dash.cloudflare.com','https://www.cloudflare.com']"
check-for-dead-internal-links:
name: Check internal links
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18

- name: Install deps
run: npm install

- name: test build
run: npm run clean && npm run build

check-for-redirects:
name: Check for needed redirects
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Create suggested redirects
id: redirects
run: |
bash .github/workflows/scripts/generate-redirects.sh
- uses: ./.github/actions/create-or-update-comment
with:
pull-request: ${{ github.event.pull_request.number }}
body: ${{ steps.redirects.outputs.body }}
body-includes: following redirects
28 changes: 6 additions & 22 deletions .github/workflows/list-changed-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
env:
CHANGED_FILES: ${{ steps.changed-files.outputs.any_changed }}
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
run: |
shopt -s extglob # enable extended globbing
OUTPUT=""
Expand All @@ -36,33 +36,17 @@ jobs:
FILE_PATH=${FILE_PATH#content\/} # remove "content/"
FILE_PATH=${FILE_PATH%.mdx} # remove ".mdx"
FILE_PATH=${FILE_PATH%index} # remove "index"
OUTPUT+="| [${file}](https://www.prisma.io/docs/${FILE_PATH}) | [${file}](https://${BRANCH_NAME}.docs-51g.pages.dev/${FILE_PATH}) |%0A"
OUTPUT+="| [${file}](https://www.prisma.io/docs/${FILE_PATH}) | [${file}](https://${BRANCH_NAME//\//-}.docs-51g.pages.dev/${FILE_PATH}) |%0A"
done
else
OUTPUT="No files changed."
fi
echo "::set-output name=body::$OUTPUT"
shopt -u extglob # disable extended globbing
- name: Find existing comment
uses: peter-evans/find-comment@v3
id: find-existing
- name: Post comment
uses: ./.github/actions/create-or-update-comment
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: 'original | preview'

- name: Create comment
if: steps.find-existing.outputs.comment-id == ''
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ github.event.pull_request.number }}
pull-request: ${{ github.event.pull_request.number }}
body: ${{ steps.build-comment-body.outputs.body }}

- name: Update comment
if: steps.find-existing.outputs.comment-id != ''
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.find-existing.outputs.comment-id }}
body: ${{ steps.build-comment-body.outputs.body }}
edit-mode: replace
body-includes: 'original | preview'
19 changes: 5 additions & 14 deletions .github/workflows/scripts/generate-redirects.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

body="This PR probably requires the following redirects to be added to vercel.json:%0A%0A"
body="## Redirect check%0AThis PR probably requires the following redirects to be added to static/_redirects:%0A%0A"
no_changed_pages="%0A- This PR does not change any pages in a way that would require a redirect."

echo $GITHUB_BASE_REF
Expand All @@ -10,7 +10,7 @@ git reset --soft origin/$GITHUB_BASE_REF
git status -s
status=$(git status -s)

while IFS= read -r line
while IFS= read -r line
do
# Split line into parts
IFS=' '
Expand All @@ -23,7 +23,7 @@ do
if [[ "${values[0]}" != "D" && "${values[0]}" != "R" ]]; then
continue
fi

# Delete msg for no edited pages and start code block
if [ -n "$no_changed_pages" ]; then
no_changed_pages=""
Expand All @@ -43,26 +43,18 @@ do
# clean paths
path1_cleaned=$(echo "$path1" | sed -E 's:content/:/:g' | sed -e 's/.mdx//g' | sed -E 's:/[0-9]+-:/:g' )
path2_cleaned=$(echo "$path2" | sed -E 's:content/:/:g' | sed -e 's/.mdx//g' | sed -E 's:/[0-9]+-:/:g' )

# special case for deletion
if [[ "${values[0]}" == "D" ]]; then
path2_cleaned="/##( TODO: Path of page that replaces deleted page )##"
fi

redirect=$(cat <<-END
{
"source": "/docs$path1_cleaned",
"destination": "/docs$path2_cleaned"
},
redirect="$path1_cleaned /docs$path2_cleaned"

END
)
echo $redirect
echo ""
body="$body$redirect%0A"

#echo "foo"


done < <(printf '%s\n' "$status")

Expand All @@ -71,4 +63,3 @@ body=$(echo "$body" | sed ':a;N;$!ba;s/\n/%0A/g')
echo $body

echo "::set-output name=body::$body"

Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ This is way more convenient and comes closer to the mental model developers have

> ORM represents a quagmire which starts well, gets more complicated as time passes, and before long entraps its users in a commitment that has no clear demarcation point, no clear win conditions, and no clear exit strategy.
>
> [The Vietnam of Computer Science, Ted Neward (2006)](http://blogs.tedneward.com/post/the-vietnam-of-computer-science/)
> [The Vietnam of Computer Science, Ted Neward (2006)](https://web.archive.org/web/20220823105749/http://blogs.tedneward.com/post/the-vietnam-of-computer-science/)
As an application developer, the mental model you have for your data is that of an _object_. The mental model for data in SQL on the other hand are _tables_.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ No matter if you're a SQL newcomer or veteran, Prisma ORM will give you a signif

Here are a couple of the guiding principles and general practices we apply when designing and building our tools:

- [make the right thing easy](https://git.io/right-thing-easy-thing)
- [make the right thing easy](https://jason.energy/right-thing-easy-thing/)
- [pit of success](https://blog.codinghorror.com/falling-into-the-pit-of-success/)
- offer intelligent autocompletion where possible
- build powerful editor extensions (e.g. for [VS Code](https://marketplace.visualstudio.com/items?itemName=Prisma.prisma))
Expand Down
25 changes: 0 additions & 25 deletions content/200-orm/050-overview/500-databases/950-cloudflare-d1.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -145,22 +145,6 @@ npx wrangler d1 migrations apply __YOUR_DATABASE_NAME__ --remote

For any further migrations, you can use the same workflow but instead of using `--from-empty`, you'll need to use `--from-local-d1` because your source schema for the `prisma migrate diff` command now is the current schema of that local D1 instance, while the target remains your (then updated) Prisma schema.

<!-- For any further migrations, you can use the same workflow but instead of using `--from-empty`, you'll need to use `--from-url __FILE_PATH_` (where `__FILE_PATH_` points to your local D1 instance) because your source schema for the `prisma migrate diff` command now is the current schema of that local D1 instance, while the target remains your (then updated) Prisma schema. -->

<!-- #### 1. Locate the SQLite database file in `.wrangler`

Your local D1 instance is represented by a SQLite database file that's stored in `./wrangler/state/d1`. Locate this file and grab the full path to the SQLite database instance. It likely looks similar to this:

```no-copy
./.wrangler/state/v3/d1/miniflare-D1DatabaseObject/0fee8d0e0152078a4a36c1a547dec875c1c7aa598e931fbbefdd7bff19d3d60d.sqlite
```

Keep this file path handy since you'll need it for any future migrations. The instructions will refer to the file path as:

```
./.wrangler/state/v3/d1/miniflare-D1DatabaseObject/__YOUR_DB__.sqlite
``` -->

#### 1. Update your Prisma data model

Assume you have updated your Prisma schema with another model:
Expand Down Expand Up @@ -211,15 +195,6 @@ npx prisma migrate diff \
--output migrations/0002_create_post_table.sql
```

<!-- ```terminal
npx prisma migrate diff \
--from-url file:./.wrangler/state/v3/d1/miniflare-D1DatabaseObject/__YOUR_DB__.sqlite \
--to-schema-datamodel ./prisma/schema.prisma \
--script > migrations/0002_create_post_table.sql
```
> **Note**: Remember that you need to replace `__YOUR_DB__` with the long string of numbers and characters that represent the file name of your local D1 instance. -->
The command above uses the following options:

- `--from-local-d1`: The source for the SQL statement is the local D1 database file.
Expand Down
20 changes: 0 additions & 20 deletions content/200-orm/100-prisma-schema/10-overview/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -263,26 +263,6 @@ block _ {
}
```

<!--
Multiline objects follow their own nested formatting rules:

```
block _ {
key = "value"
key2 = 1
key10 = {
a = "a"
b = "b"
}
key10 = [
1,
2
]
}

```
-->

#### Field definitions are aligned into columns separated by 2 or more spaces

```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,6 @@ However, when you _create_ a record, Prisma ORM does not emulate any foreign key

When you _update_ or _delete_ a record with related records, Prisma ORM will emulate referential actions.

<!-- TODO: list actions with brief description? -->

The following table shows which emulated referential actions are available for each database connector:

| Database | Cascade | Restrict | NoAction | SetNull | SetDefault |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ Take the following example, here a relation table is created to act as the JOIN

The back relation fields are missing from the `Post` to `PostCategories` and `Category` to `PostCategories` models.

<!-- prettier-ignore-start -->

```prisma
// This example schema shows how NOT to define an explicit m-n relation
Expand All @@ -175,7 +175,7 @@ model Category {
posts Post[] // This should refer to PostCategories
}
```
<!-- prettier-ignore-end -->


To fix this the `Post` model needs to have a many relation field defined with the relation table `PostCategories`. The same applies to the `Category` model.

Expand Down
Loading

0 comments on commit 97b9008

Please sign in to comment.