Skip to content

Commit

Permalink
fix: migration diff step n tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tericcabrel committed Sep 1, 2024
1 parent def4bff commit db64238
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 45 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/migration-db-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,6 @@ jobs:
echo "" >> migration-message.txt
echo "Please ensure your schema changes are compatible with the application code currently running in production." >> migration-message.txt
# - name: Comment pull request with the migration diff
# uses: thollander/actions-comment-pull-request@v2
# with:
# filePath: packages/domain/migration-message.txt

- name: Create or update the pull request with the migration diff
uses: actions/github-script@v6
id: plan-comment
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Snipcode is an open-source code-sharing platform that makes it easy to create co
* [Node.js](https://nodejs.org/en/)
* [TypeScript](https://www.typescriptlang.org/)
* [GraphQL](https://graphql.org/)
* [MySQL 8 with PlanetScale](https://planetscale.com/)
* [MySQL 8.0](https://dev.mysql.com/doc/refman/8.0/en/)
* [Prisma](https://www.prisma.io/)
* [Tailwind CSS](https://tailwindcss.com/)
* [AWS](https://aws.amazon.com)
Expand All @@ -29,11 +29,9 @@ snipcode
│ ├─ backend
│ ├─ web
├─ packages
│ ├─ database
│ ├─ embed
│ ├─ domain
│ ├─ front
│ ├─ logger
│ ├─ utils
package.json
tsconfig.base.json
Expand Down
4 changes: 2 additions & 2 deletions apps/backend/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Snipcode Core
# Snipcode Backend

This is the backend of Snipcode, containing the business logics related to .

Expand All @@ -15,7 +15,7 @@ Make sure you have these tools installed before running the project
* NPM or Yarn
* Docker
* AWS CLI v2
* MySQL 8 on PlanetScale
* MySQL 8.0

## Packages dependencies
We use Yarn workspace to create packages we can share with other applications.
Expand Down
2 changes: 2 additions & 0 deletions apps/backend/src/utils/tests/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ export class TestHelper {
await prismaService.snippet.deleteMany();

// Recursive relationship between folders makes it hard to delete all folders using folder.deleteMany()
await prismaService.$executeRaw`SET FOREIGN_KEY_CHECKS=0;`;
await prismaService.$executeRaw`TRUNCATE TABLE folders;`;
await prismaService.$executeRaw`SET FOREIGN_KEY_CHECKS=1;`;

await prismaService.session.deleteMany();

Expand Down
44 changes: 9 additions & 35 deletions packages/domain/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ Make sure you have this tools installed before running the project
* Node.js 20+
* Yarn 4
* Docker
* [The PlanetScale CLI](https://planetscale.com/cli)

## Set up the project
Delete the existing folders output from build commands
Expand All @@ -29,42 +28,23 @@ Create the .env file from the template. This file is useful for test executions,
cp .env.template .env
```

Create git branch for your feature; there is no convention for the branch name.
### Start the local database and run the migrations
```shell
git checkout -b your-feature-name
```

### Connect to the local database locally
This project uses PlanetScale as the database.<br>
To connect to the database locally, you must authenticate first (Ask the credentials to [@tericcabrel](https://github.com/tericcabrel)).<br>
Once authenticated from the terminal, execute the commands below to create a database branch for your feature and create local tunnel to it.
```shell
yarn db:branch:dev
yarn db:branch:connect
```
Open a second terminal and run the command below to start the shadow database;
this is only necessary to run generate or execute database migrations with prisma schema
```shell
yarn db:shadow
yarn db:local
yarn db:migrate
```

The shadow database runs on Docker, you can stop it when you don't need it
### Generate Prisma types and seed the database with default data
```shell
yarn db:shadow:stop
yarn db:generate
yarn db:seed
```

### Connect to the development database
The development database is used to beta test features. Execute the command below to connect to it
To stop the local database run the command below:
```shell
yarn db:dev:connect
yarn db:local:stop
```

### Run the database migration, generate Prisma types and seed the database with default data
```shell
yarn db:generate
yarn db:migrate
yarn db:seed
```

### Generate a database migration
To create a database migration that generate the SQL file, run the command below:
Expand All @@ -78,13 +58,7 @@ yarn db:migrate --name <migration-name>
- Open Prisma Studio to browse your database: `db:view`
- Lint the Prisma schema file: `db:format`

### Create a deployment request
To publish the database schema changes in production, you must create a deployment request. Run the command below to do that
```shell
yarn db:deploy:create
```

Build the package to generate types declaration required to provide autocompletion while using the functions in the core or Lambda functions
Build the package to generate types declaration required to provide autocompletion while using the functions in the backend application
```bash
yarn build
```
Expand Down
Empty file.

0 comments on commit db64238

Please sign in to comment.