Skip to content

Commit 6e801f2

Browse files
authored
Add a simple populate script (#880)
* Add a simple populate script * readme changes * add `all` flag * add logging everywhere
1 parent 6805015 commit 6e801f2

File tree

4 files changed

+1052
-39
lines changed

4 files changed

+1052
-39
lines changed

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,3 +616,37 @@ npm run updateLocalEnv
616616
```
617617

618618
This will replace your `.env.local` file with the one that will be used in prod (simply taking `.env.template + .env.SECRET_CONFIG`).
619+
620+
### Populate database
621+
622+
> [!WARNING]
623+
> The `MONGODB_URL` used for this script will be fetched from `.env.local`. Make sure it's correct! The command runs directly on the database.
624+
625+
You can populate the database using faker data using the `populate` script:
626+
627+
```bash
628+
npm run populate <flags here>
629+
```
630+
631+
At least one flag must be specified, the following flags are available:
632+
633+
- `reset` - resets the database
634+
- `all` - populates all tables
635+
- `users` - populates the users table
636+
- `settings` - populates the settings table for existing users
637+
- `assistants` - populates the assistants table for existing users
638+
- `conversations` - populates the conversations table for existing users
639+
640+
For example, you could use it like so:
641+
642+
```bash
643+
npm run populate reset
644+
```
645+
646+
to clear out the database. Then login in the app to create your user and run the following command:
647+
648+
```bash
649+
npm run populate users settings assistants conversations
650+
```
651+
652+
to populate the database with fake data, including fake conversations and assistants for your user.

0 commit comments

Comments
 (0)