Skip to content

Commit

Permalink
chore(database): remove isfavorite column (#71)
Browse files Browse the repository at this point in the history
* chore(database): remove isfavorite column

* fix: tests in the ci
build(database): target the pr branch when applying migrations (#72)

* build(database): target the pr branch when applying migrations

* fix: ci

* fix: ci

* fix: ci

* fix: ci
build(database): target the pr branch when applying migrations (#73)


build(database): target the pr branch when applying migrations (#75)


build(database): target the pr branch when applying migrations (#76)


build(database): target the pr branch when applying migrations (#77)


build(database): target the pr branch when applying migrations (#78)
  • Loading branch information
tericcabrel committed Jun 23, 2024
1 parent ebe0175 commit f9c5d86
Show file tree
Hide file tree
Showing 12 changed files with 70 additions and 21 deletions.
38 changes: 35 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ jobs:
DATABASE_URL: mysql:https://root:[email protected]:3306/test
CONVERTKIT_API_KEY: api_key
CONVERTKIT_FORM_ID: form_id
outputs:
releasedPackages: ${{ steps.releasedPackages.outputs.versions }}
steps:
- uses: actions/checkout@v4

Expand All @@ -46,11 +44,41 @@ jobs:
yarn prisma migrate dev --schema=packages/domain/prisma/schema.prisma
yarn test -- --runInBand --coverage
preview-frontend:
should-preview-frontend:
runs-on: ubuntu-latest
environment: 'Preview'
needs:
- build
outputs:
frontendChanged: ${{ steps.frontend-changed.outputs.any_changed }}
steps:
- uses: actions/checkout@v4

- name: Check if frontend files changed
id: frontend-changed
uses: tj-actions/changed-files@v44
with:
files_yaml: |
apps:
- apps/web/**
packages:
- packages/front/**
- name: Run step if test file(s) change
env:
ALL_CHANGED_FILES: ${{ steps.frontend-changed.outputs.all_changed_files }}
run: |
echo "Change state: ${{ steps.frontend-changed.outputs.any_changed }}"
echo "One or more test file(s) has changed."
echo "List all the files that have changed: $ALL_CHANGED_FILES"
preview-frontend:
runs-on: ubuntu-latest
environment: 'Preview'
needs:
- should-preview-frontend
if: ${{ needs.should-preview-frontend.frontendChanged == 'true' }}
steps:
- uses: actions/checkout@v4

Expand All @@ -60,15 +88,19 @@ jobs:
yarn set version 4.2.2
- name: Install Vercel CLI
if: ${{ success() }}
run: npm install --global vercel@latest

- name: Pull Vercel Environment Information
if: ${{ success() }}
run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}

- name: Build Project Artifacts
if: ${{ success() }}
env:
APP_VERSION:
run: vercel build --token=${{ secrets.VERCEL_TOKEN }}

- name: Deploy Project Artifacts to Vercel
if: ${{ success() }}
run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }}
15 changes: 10 additions & 5 deletions .github/workflows/migration-db-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,18 @@ jobs:
- name: Setup pscale
uses: planetscale/setup-pscale-action@v1

- name: Set database branch name
run: echo "PSCALE_BRANCH_NAME=$(echo ${{ github.head_ref }} | tr -cd '[:alnum:]-'| tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV

- name: Get the deploy request number in development branch
- name: Get the deploy request number and branch name in development branch
run: |
DEV_DEPLOY_REQUEST_NUMBER=$(pscale deploy-request show ${{ secrets.PLANETSCALE_DATABASE_NAME }} ${{ env.PSCALE_BRANCH_NAME }} --org ${{ secrets.PLANETSCALE_ORG_NAME }} -f json | jq -r '.number')
DEPLOYER_REQUEST_LIST=$(pscale deploy-request list ${{ secrets.PLANETSCALE_DATABASE_NAME }} --org ${{ secrets.PLANETSCALE_ORG_NAME }} -f json)
DEV_DEPLOY_REQUEST_NUMBER=$(echo "$DEPLOYER_REQUEST_LIST" | jq -r '.[] | select(.into_branch == "dev" and .state == "open") | .number')
PSCALE_BRANCH_NAME=$(echo "$DEPLOYER_REQUEST_LIST" | jq -r '.[] | select(.into_branch == "dev" and .state == "open") | .branch')
if [ -z "$DEV_DEPLOY_REQUEST_NUMBER" ]; then
echo "No open deploy request found in the development branch."
exit 1
fi
echo "DEV_DEPLOY_REQUEST_NUMBER=$DEV_DEPLOY_REQUEST_NUMBER" >> $GITHUB_ENV
echo "PSCALE_BRANCH_NAME=$PSCALE_BRANCH_NAME" >> $GITHUB_ENV
- name: Check deployment state
continue-on-error: false
Expand Down
5 changes: 5 additions & 0 deletions apps/backend/src/features/folders/graphql/folder.resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,9 @@ export class FolderResolvers {

return folders.length + snippets.length;
}

@ResolveField()
async isFavorite(@Parent() _folder: Folder): Promise<boolean> {

Check warning on line 123 in apps/backend/src/features/folders/graphql/folder.resolvers.ts

View workflow job for this annotation

GitHub Actions / build

'_folder' is defined but never used
return false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
Warnings:
- You are about to drop the column `is_favorite` on the `folders` table. All the data in the column will be lost.
*/
-- DropIndex
DROP INDEX `folders_is_favorite_idx` ON `folders`;

-- AlterTable
ALTER TABLE `folders` DROP COLUMN `is_favorite`;

-- CreateIndex
CREATE INDEX `folders_category_idx` ON `folders`(`category`);
3 changes: 1 addition & 2 deletions packages/domain/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ model Folder {
parentId String? @map("parent_id")
name String @db.VarChar(255)
path String? @db.Text
isFavorite Boolean @default(false) @map("is_favorite")
category FolderCategory @default(visible)
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
Expand All @@ -87,7 +86,7 @@ model Folder {
@@unique([userId, parentId, name], name: "folder_name_unique_constraint")
@@index([name])
@@index([isFavorite])
@@index([category])
@@index([userId])
@@index([parentId])
@@map("folders")
Expand Down
3 changes: 1 addition & 2 deletions packages/domain/src/services/folders/folder.service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ describe('Test Folder service', () => {
const expectedFolder = await folderService.create(createFolderInput);

expect(expectedFolder).toMatchObject({
category: 'visible',
id: createFolderInput.toFolder().id,
isFavorite: false,
name: createFolderInput.name,
parentId: rootFolder.id,
userId: user.id,
Expand Down Expand Up @@ -354,7 +354,6 @@ describe('Test Folder service', () => {
category: 'visible',
createdAt: expect.any(Date),
id: folder.id,
isFavorite: false,
name: folderToUpdate.name,
parentId: rootFolder.id,
path: folder.path,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ describe('Test Create Folder Input', () => {
category: 'visible',
createdAt: expect.any(Date),
id: expect.any(String),
isFavorite: false,
name: 'blogs',
parentId: 'cl23rzwe5000002czaedc8sll',
path: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export class CreateFolderInput {
category: 'visible',
createdAt: new Date(),
id: this.folderId,
isFavorite: false,
name: this._input.name,
parentId: this._input.parentId,
path: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ describe('Test Create User Root Folder Input', () => {
category: 'visible',
createdAt: expect.any(Date),
id: expect.any(String),
isFavorite: false,
name: '__dm34saxf6111113dabfed9tmm__',
parentId: null,
path: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export class CreateUserRootFolderInput {
category: 'visible',
createdAt: new Date(),
id: this.folderId,
isFavorite: false,
name: `__${this._userId}__`,
parentId: null,
path: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ describe('Test Update Folder Input', () => {
category: 'visible',
createdAt: currentFolder.createdAt,
id: currentFolder.id,
isFavorite: currentFolder.isFavorite,
name: 'folder updated',
parentId: currentFolder.parentId,
path: currentFolder.path,
Expand Down
10 changes: 6 additions & 4 deletions packages/front/.eslintrc.json → packages/front/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
{
module.exports = {
"root": true,
"extends": "../../.eslintrc.json",
"ignorePatterns": [
"postcss.config.js",
"tailwind.config.js",
"jest.config.ts",
"generated.ts"
"generated.ts",
'.eslintrc.js'
],
"parserOptions": {
"ecmaVersion": 2023,
"sourceType": "module",
"project": "tsconfig.json"
"project": "tsconfig.json",
tsconfigRootDir: __dirname,
}
}
};

0 comments on commit f9c5d86

Please sign in to comment.