ENG-1519: Add legacy-to-blockprops migration, remove backedBy from schemea#876
Conversation
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
📝 WalkthroughWalkthroughThe PR removes the Changes
Sequence DiagramsequenceDiagram
participant Init as Initialization
participant LegacyReader as Legacy Settings Reader
participant Validator as Schema Validator
participant BlockProps as Block Properties Writer
participant Storage as Marker Storage
Init->>Init: Start initSchema
Init->>LegacyReader: Call migrateGraphLevel()
LegacyReader->>LegacyReader: Read legacy feature flags, global, & discourse node settings
LegacyReader->>Validator: Validate against FeatureFlagsSchema, GlobalSettingsSchema, etc.
Validator->>Validator: Compare against defaults & existing props
Validator->>BlockProps: Write block properties if needed
BlockProps->>Storage: Write migration marker block on success
Storage-->>Init: Migration complete
Init->>LegacyReader: Call migratePersonalSettings()
LegacyReader->>LegacyReader: Read personal settings
Validator->>BlockProps: Write personal settings to block props
BlockProps->>Storage: Set personal settings marker
Storage-->>Init: Personal migration complete
Init->>Init: Initialize discourse node pages
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| .optional() | ||
| .transform((val) => val ?? defaultNodeIndex()), | ||
| suggestiveRules: SuggestiveRulesSchema.default({}), | ||
| backedBy: z |
There was a problem hiding this comment.
We do not need to have the backedBy in the schema, in the legacy settings we set the backedBy at the runtime, we do not save it anywhere in the blocks
| export const migratePersonalSettings = async ( | ||
| blockUids: Record<string, string>, | ||
| ): Promise<void> => { | ||
| if (getSetting<boolean>(PERSONAL_MIGRATION_MARKER, false)) { |
There was a problem hiding this comment.
Personal settings is per user so we check if this user's personal settings have migrated or not, it could be the case that all the global and discourse node settings have migrated but not the user's personal settings
|
|
||
| export const initSchema = async (): Promise<InitSchemaResult> => { | ||
| const blockUids = await initSettingsPageBlocks(); | ||
| await migrateGraphLevel(blockUids); |
There was a problem hiding this comment.
This runs before initDiscourseNodePages() on purpose. The init check for “do we already have user discourse nodes?” only looks at block props, so legacy node pages without migrated props would be invisible there and the graph could be mistaken for an empty graph. Running migration first makes those existing legacy node pages visible to the new-store check before default node seeding happens.
…cy-to-blockprops-migration
| }; | ||
|
|
||
| // Reconstructs global settings from getFormattedConfigTree() shape to match block-props schema shape | ||
| // Reconstructs global settings from legacy Roam tree to match block-props schema shape |
There was a problem hiding this comment.
Moving away from getFormattedConfigTree()
mdroidian
left a comment
There was a problem hiding this comment.
Approved. One small change from backend to async for the query.
I also added a few additional devin comments, let's take a second to review/resolve them before merging 👍
https://www.loom.com/share/f7367e084c2e424eb20e31fdfd937d14
Summary by CodeRabbit