@@ -158,14 +158,26 @@ if what you need to seed is a lot of data), so here's an easy way to help out:
158
158
159
159
1 . Create a script very similar to our ` prisma/seed.ts ` file which creates all
160
160
the data you want to seed.
161
- 1 . Run the script locally to generate the data you want to seed.
161
+ ``` sh nonumber
162
+ cp prisma/seed.ts ./prod-seed.local.ts
163
+ ```
164
+ Then modify that file to create the data you want to seed.
165
+ 1 . Create a temporary database file to seed the data into.
166
+ ``` sh
167
+ DATABASE_URL=file:./seed.local.db npx prisma migrate reset --skip-seed --force
168
+ ```
169
+ 1 . Run the custom seed script locally to generate the data you want to seed.
170
+ ``` sh
171
+ DATABASE_URL=file:./seed.local.db npx tsx ./prod-seed.local.ts
172
+ ```
162
173
1 . Create a "dump" of the seed database using the ` sqlite3 ` command line tool.
163
174
``` sh nonumber
164
- sqlite3 seed.db .dump > seed.sql
175
+ sqlite3 ./prisma/ seed.local. db .dump > seed.local .sql
165
176
```
166
- 1 . Copy the relevant bits from the ` seed.sql ` file into your ` migration.sql `
167
- file. The ` seed.sql ` will include create table/index lines etc. which should
168
- already be in your ` migration.sql ` . You probably just want ` INSERT ` commands.
177
+ 1 . Copy the relevant bits from the ` seed.local.sql ` file into your
178
+ ` migration.sql ` file. The ` seed.local.sql ` will include create table/index
179
+ lines etc. which should already be in your ` migration.sql ` . You probably just
180
+ want ` INSERT ` commands.
169
181
1 . Deploy your app and verify that the data was seeded correctly.
170
182
171
183
If your app has already applied all migrations, then the changes to the
0 commit comments