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
  • Loading branch information
tericcabrel authored Jun 22, 2024
1 parent ebe0175 commit 77b87dc
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 9 deletions.
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,14 @@
/*
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

0 comments on commit 77b87dc

Please sign in to comment.