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

Add Telescope Prisma docs #3503

Merged
merged 2 commits into from
Apr 17, 2022
Merged

Add Telescope Prisma docs #3503

merged 2 commits into from
Apr 17, 2022

Conversation

DukeManh
Copy link
Contributor

@DukeManh DukeManh commented Apr 16, 2022

Issue This PR Addresses

Write docs to Manage DB with Prisma

Type of Change

  • Bugfix: Change which fixes an issue
  • New Feature: Change which adds functionality
  • Documentation Update: Change which improves documentation
  • UI: Change which improves UI

Description

Steps to test the PR

Checklist

  • Quality: This PR builds and passes our npm test and works locally
  • Tests: This PR includes thorough tests or an explanation of why it does not
  • Screenshots: This PR includes screenshots or GIFs of the changes made or an explanation of why it does not (if applicable)
  • Documentation: This PR includes updated/added documentation to user exposed functionality or configuration variables are added/changed or an explanation of why it does not(if applicable)

@gitpod-io
Copy link

gitpod-io bot commented Apr 16, 2022

tcvan0707
tcvan0707 previously approved these changes Apr 17, 2022
Copy link
Contributor

@humphd humphd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent, thanks for this.

src/web/docusaurus/docs/tools-and-technologies/prisma.md Outdated Show resolved Hide resolved

```bash
cd src/db
cp env.example .env
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: should we default to this somehow vs. making it a requirement? That is, do we ever need to change the values in this file? If not, maybe we should hard-code it into the script.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we don't have a way to run migrations on the remote DB.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we hardcode the DATABASE_URL if the DB password on dev and production are different?

src/web/docusaurus/docs/tools-and-technologies/prisma.md Outdated Show resolved Hide resolved

### Custom migration

Sometimes, we want to make changes other than the modifying the schema, for example, adding new RLS to a table. We can do so by creating an empty migration file, which is an empty SQL script where we write our own SQL queries to be apply to the database.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use this to somehow include a migration for setting up the local db, but not run it by default in any environment other than dev?

I want to insert a user + feed based on #3501

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think it should be possible to have INSERT statements in the migration.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think all migrations will be included. To seed the DB, people often run a script.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, so we need to do this outside of migrations. We'll have to think about how to do it best, so we don't do it in tests, and we don't rely on users to do it locally (new users won't, it will be annoying to do it every time for regular devs).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking of putting the seed script can be src/db, making it read from a JSON file containing the example data. We call the script in pnpm services:start.

@DukeManh DukeManh merged commit e333de1 into Seneca-CDOT:master Apr 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: documentation (docs) Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants