Starchart: Planning Toward Release 0.1
Tags: webdev, javascript, opensource, prisma
Published: 2023-01-28 03:49:52

This week, we some planning for [Starchart](https://github.com/Seneca-CDOT/starchart) release 0.1.
The first waves of issues were filed, and tasks were assigned to the team members. I'm to contribute in setting up database schema and the ORM, [Prisma](https://www.prisma.io/), as well as finding out how to run it in [Docker](https://www.docker.com/).

## My Issues
**I filed 7 issues in total:**
[Issue #6](https://github.com/Seneca-CDOT/starchart/issues/6) is about adding a wiki entry for Prisma to serve as a start point for helping team members looking into the technology.
[Issue #9](https://github.com/Seneca-CDOT/starchart/issues/9) is about notifying users about their SSL certificate request status via email
[Issue #10](https://github.com/Seneca-CDOT/starchart/issues/10) centers around creating a page for user to view information of SSL certificate they have requested.
[Issue #11](https://github.com/Seneca-CDOT/starchart/issues/11) talks about a feature to notify users about their SSL certificate expiration and next-steps
[Issue #12](https://github.com/Seneca-CDOT/starchart/issues/12) is regarding documentation for helping developers setup their local environment for development of this project.
[Issue #13](https://github.com/Seneca-CDOT/starchart/issues/13) is regarding documentation for helping developers follow flow of contribution to contribute to the project.
[Issue #16](https://github.com/Seneca-CDOT/starchart/issues/16) is for creating a certificate table in the database to record information of SSL certificate created.


## Technology Research
Because much of the tech stack is new to me, I have to spend time reading the documentations to familiarize myself with it.
Since I try to focus on database, my primary focus is on MySQL and Prisma, which is the primary way the project uses to interact with a MySQL database. 
In my research, I found information for how to [set up Prisma](https://www.prisma.io/docs/getting-started/setup-prisma/start-from-scratch/relational-databases-typescript-postgres) for a MySQL database, and I have tried the steps.
Through commands, one can run a .prisma file to push/pull table schema to/from the target database. One can also run commands to run a file with code that essentially act like SQL statements.

**Here are some basic CLI commands:**

- `npx prisma db pull` to pull database tables into your schema file.
- `npx prisma generate` to sync client to current schema in the local schema file; do this before you do CRUD SQL operation via prisma.
- `npx ts-node <file location>` to execute CRUD operation code in the file.
- `npx prisma migrate dev --name <any migration name>` to migrate your schema.prisma file to target database.
Because prisma make a shadow database (temporary) every time to make sure database is sync, use `npx prisma database push` if you don’t have right to make another database (no benefit from shadow database)
- `npx prisma studio` to start Prisma studio, the visual editor UI for database.

------------

Also, I tried to look up how to run MySQL database in Docker. It seems you need to download an image of a MySQL database, and then create an instance in Docker, as detailed on [MySQL's website](https://dev.mysql.com/doc/mysql-installation-excerpt/8.0/en/docker-mysql-getting-started.html#docker-starting-mysql-server).
The Docker documentation suggests an one-line command to do so:`docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:tag`.