Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seed database with data from the downloaded archives #159

Merged
merged 12 commits into from
Nov 12, 2024
Merged
9 changes: 7 additions & 2 deletions docs/local-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,15 @@ For each change you make to the db:

### Seeding the local database

- Download the last export from [the Github Releases](https://github.com/TheExGenesis/community-archive/releases)
- make sure your `.env` file has `NEXT_PUBLIC_SUPABASE_URL` and `NEXT_PUBLIC_SUPABASE_ANON_KEY` setup to the Community Archive db
- run the script `pnpm dev:downloadarchive`
- make sure your `.env` file has `*_LOCAL_*` env vars setup to your local db
- set the `ARCHIVE_PATH` environment variable to the path of the archive folder
- run the script `pnpm dev:importdata`
- run the script `pnpm dev:importfiles`
- wait a bit and then you should be able to see the data in the local supabase studio at http://localhost:54323/project/default/editor
- (OPTIONAL)run the script `pnpm dev:validateimport` to validate the data. afaict there's a few edge cases where the data might not import correctly. For now fixing this is not a priority, PR is welcome!

Note: this process takes a bit of time because there's 100+ archives to import. Feel free to delete some of the archives from the `ARCHIVE_PATH` folder if you want to speed up the process. Another option is finding the optimal `BATCH_SIZE` value in `scripts/importFromFilesToDb.ts` for your machine.

### Sign-in in dev mode

Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
"dev": "set NODE_ENV=development & set NEXT_PUBLIC_USE_REMOTE_DEV_DB=false & next dev",
"dev-as-prod": "set NODE_ENV=production & next dev",
"dev-remote-db": "set NEXT_PUBLIC_USE_REMOTE_DEV_DB=true & next dev",
"dev:importdata": "tsx --env-file=.env scripts/importFromArchiveDataToDb.ts",
"dev:importfiles": "tsx --env-file=.env scripts/importFromFilesToDb.ts",
"dev:validateimport": "tsx --env-file=.env scripts/validateDbImport.ts",
"dev:downloadarchive": "tsx --env-file=.env scripts/download_storage_anon.mts",
"dev:testconversationids": "tsx --env-file=.env scripts/testConversationIds.ts",
"build": "set NODE_ENV=production & next build",
"start": "next start",
Expand Down
Loading