mirror of
https://github.com/jbranchaud/til
synced 2026-01-04 23:58:01 +00:00
Add Seed Production Data Into Another Branch as a Planetscale TIL
This commit is contained in:
@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
|
|||||||
|
|
||||||
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
|
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
|
||||||
|
|
||||||
_1254 TILs and counting..._
|
_1255 TILs and counting..._
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -43,6 +43,7 @@ _1254 TILs and counting..._
|
|||||||
* [Netlify](#netlify)
|
* [Netlify](#netlify)
|
||||||
* [Next.js](#nextjs)
|
* [Next.js](#nextjs)
|
||||||
* [Phoenix](#phoenix)
|
* [Phoenix](#phoenix)
|
||||||
|
* [Planetscale](#planetscale)
|
||||||
* [pnpm](#pnpm)
|
* [pnpm](#pnpm)
|
||||||
* [PostgreSQL](#postgresql)
|
* [PostgreSQL](#postgresql)
|
||||||
* [Prisma](#prisma)
|
* [Prisma](#prisma)
|
||||||
@@ -557,6 +558,10 @@ _1254 TILs and counting..._
|
|||||||
- [Specifying The Digest Directory](phoenix/specifying-the-digest-directory.md)
|
- [Specifying The Digest Directory](phoenix/specifying-the-digest-directory.md)
|
||||||
- [Specifying The Server Port](phoenix/specifying-the-server-port.md)
|
- [Specifying The Server Port](phoenix/specifying-the-server-port.md)
|
||||||
|
|
||||||
|
### Planetscale
|
||||||
|
|
||||||
|
- [Seed Production Data Into Another Branch](planetscale/seed-production-data-into-another-branch.md)
|
||||||
|
|
||||||
### pnpm
|
### pnpm
|
||||||
|
|
||||||
- [Execute A Command From The Workspace Root](pnpm/execute-a-command-from-the-workspace-root.md)
|
- [Execute A Command From The Workspace Root](pnpm/execute-a-command-from-the-workspace-root.md)
|
||||||
|
|||||||
28
planetscale/seed-production-data-into-another-branch.md
Normal file
28
planetscale/seed-production-data-into-another-branch.md
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
# Seed Production Data Into Another Branch
|
||||||
|
|
||||||
|
When you [create a Planetscale
|
||||||
|
branch](https://planetscale.com/docs/reference/branch) off `main`, it will only
|
||||||
|
copy over the schema. No data will be copied over to that new branch.
|
||||||
|
|
||||||
|
You can copy data over from the initial branch (`main`) in two steps from the
|
||||||
|
CLI. First, create a dump of the branch. Then restore the dump into your new
|
||||||
|
branch.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ pscale database dump database-name main --output ./dump
|
||||||
|
```
|
||||||
|
|
||||||
|
That creates SQL files locally in the `dump` folder with both schema and data
|
||||||
|
statements.
|
||||||
|
|
||||||
|
That folder of SQL files can then be restored into one of your branches.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ pscale database restore-dump database-name branch-name --dir ./dump --overwrite-tables
|
||||||
|
```
|
||||||
|
|
||||||
|
The `--overwrite-tables` flag is needed because your branch's existing schema
|
||||||
|
will conflict with the `create` schema statements in the SQL files.
|
||||||
|
|
||||||
|
You can `pscale shell` into that branch and run a `select ...` statement to
|
||||||
|
check out the data.
|
||||||
Reference in New Issue
Block a user