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

refactor(core): Delete boilerplate code across migrations (no-changelog) #5254

Merged
merged 15 commits into from
May 5, 2023

Conversation

netroy
Copy link
Member

@netroy netroy commented Jan 25, 2023

This is part one of streamlining migrations code. Part two will be switching to a DSL that auto-generates the db specific queries from a single code.

This also enables linting on migrations.

DB Tests

@n8n-assistant n8n-assistant bot added core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team labels Jan 25, 2023
@netroy netroy force-pushed the cleanup-migrations branch 3 times, most recently from 517a482 to e5118c7 Compare January 30, 2023 12:10
Copy link
Contributor

@flipswitchingmonkey flipswitchingmonkey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see note

krynble
krynble previously approved these changes Feb 13, 2023
Copy link
Contributor

@krynble krynble left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems ok, tested starting n8n with all databases, all executed fine.

@github-actions
Copy link
Contributor

Great PR! Please pay attention to the following items before merging:

Files matching packages/**:

  • If fixing bug, added test to cover scenario.
  • If addressing forum or Github issue, added link to description.

Files matching packages/**/*.ts:

  • Added unit tests to cover new or updated functionality.

Files matching packages/cli/src/databases/migrations/**:

  • Requested review from at least two engineers on migration.
  • Avoided irreversible data migrations.
  • Avoided deleting or updating data keys.
  • Wrote 'down' migration if possible.

Make sure to check off this list before asking for review.

@codecov
Copy link

codecov bot commented Mar 29, 2023

Codecov Report

Patch coverage: 41.17% and no project coverage change.

Comparison is base (0eb4d9f) 20.06% compared to head (090732a) 20.06%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #5254   +/-   ##
=======================================
  Coverage   20.06%   20.06%           
=======================================
  Files        2622     2621    -1     
  Lines      118091   118110   +19     
  Branches    18557    18559    +2     
=======================================
+ Hits        23691    23702   +11     
- Misses      93685    93692    +7     
- Partials      715      716    +1     
Impacted Files Coverage Δ
packages/cli/src/databases/config.ts 73.68% <ø> (ø)
...ckages/nodes-base/nodes/Kafka/KafkaTrigger.node.ts 0.00% <0.00%> (ø)
...ckages/cli/src/databases/utils/migrationHelpers.ts 62.90% <63.15%> (+4.56%) ⬆️
packages/cli/src/Db.ts 56.25% <66.66%> (+1.12%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Contributor

@ivov ivov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like this! Reviewed but untested.

packages/cli/src/Db.ts Outdated Show resolved Hide resolved
packages/cli/src/databases/types.ts Outdated Show resolved Hide resolved
packages/cli/src/databases/types.ts Show resolved Hide resolved
packages/cli/src/databases/types.ts Outdated Show resolved Hide resolved
tablePrefix: string;
dbType: DatabaseType;
dbName: string;
migrationName: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to also add helpers like loadSurveyFromDisk and escapeQuery to the context? Maybe under a utils field?

packages/cli/src/databases/types.ts Outdated Show resolved Hide resolved
edumaciel10

This comment was marked as off-topic.

@netroy netroy requested a review from ivov May 4, 2023 15:43
Copy link
Contributor

@ivov ivov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! I'll test this later today. Some scattered ideas for future:

  • Any benefit to using the useStructuredResult arg to queryRunner.query()?
  • Require specifying the reason when choosing to use IrreversibleMigration?
  • Consolidate usage of escapeQueryWithParameters vs. unescaped queries?
  • Enforce double quotes on PG table names to avoid casing issues with prefixes?
  • Require the re-enabling PRAGMA statement after a disabling one on sqlite?
  • Unify isObjectLiteral which is used in four different spots across packages?

Copy link
Contributor

@ivov ivov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on sqlite, MySQL 8, PG 13.8 (regular, alt schema, table prefix)

@github-actions
Copy link
Contributor

github-actions bot commented May 5, 2023

✅ All Cypress E2E specs passed

@netroy netroy merged commit 82fe638 into master May 5, 2023
@netroy netroy deleted the cleanup-migrations branch May 5, 2023 09:29
MiloradFilipovic added a commit that referenced this pull request May 5, 2023
* master:
  fix(FTP Node): Use filename instead of remote filepath for downloaded binary data (#6170)
  ci: Fix test database cleanup (no-changelog) (#6188)
  refactor(core): Delete boilerplate code across migrations (no-changelog) (#5254)
  refactor(editor): Add infix to Pinia stores (no-changelog) (#6149)
  ci: Fix linting issues on master (no-changelog) (#6186)
MiloradFilipovic added a commit that referenced this pull request May 9, 2023
* master: (31 commits)
  feat(Date & Time Node): Overhaul of the node (#5904)
  refactor: Add deprecation notice for WEBHOOK_TUNNEL_URL (#6194)
  refactor: Add deprecation notice for WEBHOOK_TUNNEL_URL (#6194)
  feat(HubSpot Node): Overhaul the HubSpot Node (#4337)
  ci: Create a nightly v1 docker image (no-changelog) (#6197)
  refactor(core): Add deprecation notice for own mode (#6195)
  feat(core): Update config defaults for for v1 (no-changelog) (#6196)
  test(Read Binary Files Node): Unit tests (no-changelog) (#5459)
  refactor: Add deprecation notice for MySQL and MariaDB (#6189)
  test: Create custom jest error messages using jest-expect-message (no-changelog) (#5666)
  fix(core): Move nodeExecute InternalHook calls to hookFunctionsSave (#6193)
  fix(FTP Node): Use filename instead of remote filepath for downloaded binary data (#6170)
  ci: Fix test database cleanup (no-changelog) (#6188)
  refactor(core): Delete boilerplate code across migrations (no-changelog) (#5254)
  refactor(editor): Add infix to Pinia stores (no-changelog) (#6149)
  ci: Fix linting issues on master (no-changelog) (#6186)
  fix(editor): Update and add design system checkbox component to Editor (#6178)
  fix(editor): Display SSO entry in Settings on Cloud (#6181)
  feat(Code Node): Add Python support (#4295)
  fix(editor): Update and fix storybook (was failing to run in local dev mode) (#6180)
  ...

# Conflicts:
#	packages/editor-ui/src/stores/nodeTypes.store.ts
#	packages/nodes-base/nodes/Postgres/Postgres.node.ts
#	packages/nodes-base/nodes/Postgres/v2/actions/versionDescription.ts
MiloradFilipovic added a commit that referenced this pull request May 9, 2023
…rce-mapper-ui-P2

* feature/resource-mapping-component: (31 commits)
  feat(Date & Time Node): Overhaul of the node (#5904)
  refactor: Add deprecation notice for WEBHOOK_TUNNEL_URL (#6194)
  refactor: Add deprecation notice for WEBHOOK_TUNNEL_URL (#6194)
  feat(HubSpot Node): Overhaul the HubSpot Node (#4337)
  ci: Create a nightly v1 docker image (no-changelog) (#6197)
  refactor(core): Add deprecation notice for own mode (#6195)
  feat(core): Update config defaults for for v1 (no-changelog) (#6196)
  test(Read Binary Files Node): Unit tests (no-changelog) (#5459)
  refactor: Add deprecation notice for MySQL and MariaDB (#6189)
  test: Create custom jest error messages using jest-expect-message (no-changelog) (#5666)
  fix(core): Move nodeExecute InternalHook calls to hookFunctionsSave (#6193)
  fix(FTP Node): Use filename instead of remote filepath for downloaded binary data (#6170)
  ci: Fix test database cleanup (no-changelog) (#6188)
  refactor(core): Delete boilerplate code across migrations (no-changelog) (#5254)
  refactor(editor): Add infix to Pinia stores (no-changelog) (#6149)
  ci: Fix linting issues on master (no-changelog) (#6186)
  fix(editor): Update and add design system checkbox component to Editor (#6178)
  fix(editor): Display SSO entry in Settings on Cloud (#6181)
  feat(Code Node): Add Python support (#4295)
  fix(editor): Update and fix storybook (was failing to run in local dev mode) (#6180)
  ...

# Conflicts:
#	packages/editor-ui/src/stores/nodeTypes.store.ts
@janober
Copy link
Member

janober commented May 25, 2023

Got released with n8n@0.228.2

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 Released skip-e2e
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants