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

feat(core): Add migration to create model for folders feature #13060

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

RicardoE105
Copy link
Contributor

@RicardoE105 RicardoE105 commented Feb 5, 2025

Summary

Title self explanatory

Model

Constrains

  1. Folders can exist in only one project.
  2. Workflows can or cannot be in folder.
  3. Workflows can only be in one folder at the same time - Worklows can be in differnt
  4. Folders can have multiple tags.

ERD

CleanShot 2025-01-29 at 19 10 09@2x

Example 1: Fetching Workflows with Folder they belong to

Query

await this.workflowRepository.find({
  relations: ['folder'],
});

Response

[
  {
    "createdAt": "2025-02-03T21:38:13.346Z",
    "updatedAt": "2025-02-04T23:51:14.000Z",
    "id": "ihqEINxufYLiBEUp",
    "name": "1",
    "active": false,
    "nodes": [],
    "connections": {},
    "settings": {
      "executionOrder": "v1"
    },
    "staticData": null,
    "meta": null,
    "pinData": {},
    "versionId": "72854149-d785-40fd-8bc7-43dff1a6a441",
    "triggerCount": 0,
    "folder": null
  },
  {
    "createdAt": "2025-02-03T21:38:24.221Z",
    "updatedAt": "2025-02-03T22:07:46.000Z",
    "id": "OVscJ17q2HRd3Qqh",
    "name": "3",
    "active": false,
    "nodes": [],
    "connections": {},
    "settings": {
      "executionOrder": "v1"
    },
    "staticData": null,
    "meta": null,
    "pinData": {},
    "versionId": "561b4e5f-b23d-4fda-b18b-8b37926c95d4",
    "triggerCount": 0,
    "folder": {
      "createdAt": "2025-02-05T00:37:03.901Z",
      "updatedAt": "2025-02-05T00:37:03.901Z",
      "id": "TBuJWie3k7L0VnQ1\n",
      "name": "folder 1"
    }
  }
]

Example 2: Fetching Folders with Projects and Tags

Query

await this.folderRepository.find({
  relations: ['project', 'tags'],
  select: {
    project: {
      id: true,
      name: true,
      type: true,
      icon: {
        type: true,
        value: true,
      },
    },
    tags: {
      id: true,
      name: true,
    },
  },
});

Response

[
  {
    "createdAt": "2025-02-05T00:37:03.901Z",
    "updatedAt": "2025-02-05T00:37:03.901Z",
    "id": "TBuJWie3k7L0VnQ1\n",
    "name": "folder 1",
    "project": {
      "id": "0mhjfTCcn1vdQdaY",
      "name": "espinoza ricardo <[email protected]>",
      "type": "personal",
      "icon": null
    },
    "tags": [
      {
        "id": "3nywilz6eSljcy48",
        "name": "Name"
      }
    ]
  }
]

Related Linear tickets, Github issues, and Community forum posts

https://linear.app/n8n/issue/ADO-3164/[be]-create-migration-to-integrate-new-model

Review / Merge checklist

  • PR title and summary are descriptive. (conventions)
  • Docs updated or follow-up ticket created.
  • Tests included.
  • PR Labeled with release/backport (if the PR is an urgent fix that needs to be backported)

@RicardoE105 RicardoE105 requested a review from a team as a code owner February 5, 2025 01:03
@RicardoE105 RicardoE105 changed the title Add migration to create folder's table feat(core): Add migration to create folder's table Feb 5, 2025
@RicardoE105 RicardoE105 changed the title feat(core): Add migration to create folder's table feat(core): Add migration to create model for folder's feature Feb 5, 2025
@RicardoE105 RicardoE105 changed the title feat(core): Add migration to create model for folder's feature feat(core): Add migration to create model for folders feature Feb 5, 2025
@n8n-assistant n8n-assistant bot added core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team labels Feb 5, 2025
@RicardoE105 RicardoE105 marked this pull request as draft February 5, 2025 01:56
@RicardoE105 RicardoE105 force-pushed the ado-3164-be-create-migration-to-integrate-new-model branch from 004a380 to deff9b9 Compare February 5, 2025 02:56
Copy link

codecov bot commented Feb 5, 2025

Codecov Report

Attention: Patch coverage is 69.56522% with 7 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...li/src/databases/repositories/folder.repository.ts 0.00% 6 Missing ⚠️
packages/cli/src/databases/entities/folder.ts 92.85% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@RicardoE105 RicardoE105 marked this pull request as ready for review February 5, 2025 18:24
@RicardoE105 RicardoE105 requested review from mutdmour and tomi February 5, 2025 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant