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 tables for reporting dashboard (no-changelog) #13336

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

Conversation

despairblue
Copy link
Contributor

Summary

Add schemas according to the RFC

Related Linear tickets, Github issues, and Community forum posts

https://linear.app/n8n/issue/PAY-2581/add-reporting-analytics-to-database

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)

Copy link

codecov bot commented Feb 18, 2025

Codecov Report

Attention: Patch coverage is 66.66667% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
packages/cli/src/databases/dsl/column.ts 66.66% 4 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

@n8n-assistant n8n-assistant bot added core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team labels Feb 18, 2025
@despairblue despairblue force-pushed the pay-2581-add-reporting-analytics-to-database branch from af781a9 to 7645505 Compare February 18, 2025 13:51
@despairblue despairblue marked this pull request as ready for review February 18, 2025 16:29
@despairblue despairblue requested a review from a team as a code owner February 18, 2025 16:29
async up({ dbType, schemaBuilder: { createTable, column } }: MigrationContext) {
await createTable(names.t.analyticsMetadata)
.withColumns(
column(names.c.analyticsMetadata.metaId).int.primary.autoGenerate,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think typeorm uses SERIAL for postgres by default for auto generated columns, which is not recommended. We should instead use identity. With typeorm that can be done by specifying generationStrategy identity. I think we need to update our DSL to support this. We can't just change the current autoGenerate, as it would change how previous migrations behave

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can deprecate autoGenerate and create autoGenerate2 or I can change the default, but make it configurable and update all old migrations to override it to the old default column('foo', {defaultGenerationStrategy: 'increment'}),.

I'd prefer the first one, but it depends on people reading the deprecation notice. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could also create versions in the migrations:

export class AnyOldMigration implements ReversibleMigration {
	version: 1

	// ...
}

Based on that version another context is injected. By default it's the newest version and when we do a backward incompatible change we go back to all old migrations that don't have a version set and set it to the previous one, thus locking it in.

Copy link
Collaborator

Choose a reason for hiding this comment

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

That's an interesting approach. I kinda like it, but it does unfortunately add complexity and a new degree of freedom. After that two different installations can behave differently. I'd say let's go with your option 1: Create autoGenerateV2 and deprecate the old 👍


await createTable(names.t.analyticsRaw)
.withColumns(
column('id').int.primary.autoGenerate,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same comment here regardgin the auto generate


await createTable(names.t.analyticsByPeriod)
.withColumns(
column('id').int.primary.autoGenerate,
Copy link
Collaborator

Choose a reason for hiding this comment

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

And here

@despairblue despairblue requested a review from tomi February 21, 2025 11:14
@despairblue despairblue requested a review from tomi February 21, 2025 16:31
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.

2 participants