Prepare for schema fusion (#11922)
## Architecture Detail The goal is to merge the two TypeORM schemas. Having two schemas prevent doing things like fieldMetadata.workspace in TypeORM, and create useless debates since there is no clear line (is a serverlessFunction core or metadata? What about events? etc.) ### Before ``` ┌───────────────────┐ ┌───────────────────┐ │ core schema │ │ metadata schema │ ├───────────────────┤ ├───────────────────┤ │- User │ │- ObjectMetadata │ │- Workspace │ │- FieldMetadata │ │- UserWorkspace │ │- RelationMetadata │ │- etc. │ │- etc. │ └───────────────────┘ └───────────────────┘ ``` ### After the Migration ``` ┌───────────────────────────────────────────┐ │ engine schema │ ├───────────────────────────────────────────┤ │- User - ObjectMetadata │ │- Workspace - FieldMetadata │ │- UserWorkspace - RelationMetadata │ │- etc. - etc. │ └───────────────────────────────────────────┘ ``` ## Strategy 1. During 0.53 we backfill the *_typeorm_migrations* table of the core schema with all metadata migrations 2. That way in 0.54 we can move the metadata migrations from the metadata folder to the core folder. We will also edit the migration files to reference "core" instead of "metadata". For people doing a fresh install this will run smoothly and create the tables in Core directly. For people on an existing install, this migrations will not run because they were added to the *_typeorm_migrations* in 0.53 3. In 0.55 we will rename "core" to something else (for example "engine") Note: if someone jumps version, for example skips to 0.54 directly without having run 0.53 then this could cause issue. In 0.54 we should consider gating the "migrate:prod" in the docker file so that it's controlled and run by the upgrade command (and not run if the command wasn't executed properly)
This commit is contained in:
@ -19,6 +19,7 @@ import { UpgradeCreatedByEnumCommand } from 'src/database/commands/upgrade-versi
|
||||
import { MigrateRelationsToFieldMetadataCommand } from 'src/database/commands/upgrade-version-command/0-52/0-52-migrate-relations-to-field-metadata.command';
|
||||
import { UpgradeDateAndDateTimeFieldsSettingsJsonCommand } from 'src/database/commands/upgrade-version-command/0-52/0-52-upgrade-settings-field';
|
||||
import { BackfillWorkflowNextStepIdsCommand } from 'src/database/commands/upgrade-version-command/0-53/0-53-backfill-workflow-next-step-ids.command';
|
||||
import { CopyTypeormMigrationsCommand } from 'src/database/commands/upgrade-version-command/0-53/0-53-copy-typeorm-migrations.command';
|
||||
import { MigrateWorkflowEventListenersToAutomatedTriggersCommand } from 'src/database/commands/upgrade-version-command/0-53/0-53-migrate-workflow-event-listeners-to-automated-triggers.command';
|
||||
import { TwentyConfigService } from 'src/engine/core-modules/twenty-config/twenty-config.service';
|
||||
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
|
||||
@ -60,6 +61,7 @@ export class UpgradeCommand extends UpgradeCommandRunner {
|
||||
// 0.53 Commands
|
||||
protected readonly migrateWorkflowEventListenersToAutomatedTriggersCommand: MigrateWorkflowEventListenersToAutomatedTriggersCommand,
|
||||
protected readonly backfillWorkflowNextStepIdsCommand: BackfillWorkflowNextStepIdsCommand,
|
||||
protected readonly copyTypeormMigrationsCommand: CopyTypeormMigrationsCommand,
|
||||
) {
|
||||
super(
|
||||
workspaceRepository,
|
||||
@ -111,6 +113,7 @@ export class UpgradeCommand extends UpgradeCommandRunner {
|
||||
afterSyncMetadata: [
|
||||
this.migrateWorkflowEventListenersToAutomatedTriggersCommand,
|
||||
this.backfillWorkflowNextStepIdsCommand,
|
||||
this.copyTypeormMigrationsCommand,
|
||||
],
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user