mirror of
https://github.com/outline/outline.git
synced 2026-11-21 13:34:02 +03:00
* Migrate Backlink model to generic Relationship model - Create new Relationship model with type field to support different relationship types - Add database migration to create relationships table and migrate existing backlinks - Update Backlink model to delegate to Relationship model for backward compatibility - Update BacklinksProcessor to use Relationship model with backlink type - Update API routes to use new Relationship model - Update test files to use Relationship model - Maintain backward compatibility through database view and model delegation Fixes #9366 * Update migration to rename table instead of creating new one - Rename existing backlinks table to relationships instead of creating new table - Add type column with default value to existing table - Update existing rows to have type='backlink' - Avoid expensive data migration by keeping existing data in place - Maintain backward compatibility with database view - Update rollback to reverse table rename and column addition This approach is much more efficient for large datasets as it avoids copying millions of rows. * Remove unnecessary UPDATE statement from migration The UPDATE statement is not needed since defaultValue automatically applies to existing rows when adding a column with a default value. Thanks @tommoor for catching this! * Wrap up migration in transaction - Wrap all migration operations in a transaction for atomicity - Add transaction parameter to all queryInterface calls - Follow the same pattern as other migrations in the codebase - Ensures all operations succeed or fail together * Remove Backlink class entirely and use Relationship everywhere - Delete server/models/Backlink.ts - Remove Backlink export from server/models/index.ts - Remove Backlink import and association from Document model - All functionality now uses Relationship model with RelationshipType.Backlink - Maintains same API through Relationship model methods - Cleaner architecture with single relationship model * Update documents.test.ts to use RelationshipType enum instead of string - Import RelationshipType from Relationship model - Replace type: "backlink" with type: RelationshipType.Backlink - Improves type safety and consistency with enum usage * Address code review feedback - Add transaction wrapper to migration down method for safer rollback - Remove unused findByTypeForUser method from Relationship model - Method wasn't used and won't work for all relationship types (e.g., user mentions) - Clean up code structure and improve safety * Restore imports * Add relationships API endpoints - Create relationships API following stars pattern - Add CRUD operations: create, list, delete - Include proper validation, authentication, and authorization - Support filtering by relationship type and document IDs - Add relationship presenter and policies - Register routes in main API router * Remove relationships.create and relationships.delete endpoints - Keep only relationships.list endpoint as requested - Remove create and delete schemas from validation - Update policies to only allow read operations - Relationships will be managed internally, not via external API * Add relationships.info endpoint - Use Document.findByPk for authorization as requested - Find relationship by ID and verify user has access to related document - Return relationship details with accessible documents - Include proper validation schema for UUID parameter * Update 20250601223331-migrate-backlink-to-relationship.js * Update Relationship.ts * wip * test * Final tweaks --------- Co-authored-by: codegen-sh[bot] <131295404+codegen-sh[bot]@users.noreply.github.com> Co-authored-by: Tom Moor <tom@getoutline.com>
65 lines
1.9 KiB
TypeScript
65 lines
1.9 KiB
TypeScript
import presentApiKey from "./apiKey";
|
|
import presentAttachment from "./attachment";
|
|
import presentAuthenticationProvider from "./authenticationProvider";
|
|
import presentAvailableTeam from "./availableTeam";
|
|
import presentCollection from "./collection";
|
|
import presentComment from "./comment";
|
|
import presentDocument from "./document";
|
|
import presentEvent from "./event";
|
|
import presentFileOperation from "./fileOperation";
|
|
import presentGroup from "./group";
|
|
import presentGroupMembership from "./groupMembership";
|
|
import presentGroupUser from "./groupUser";
|
|
import presentImport from "./import";
|
|
import presentIntegration from "./integration";
|
|
import presentMembership from "./membership";
|
|
import presentOAuthClient, { presentPublishedOAuthClient } from "./oauthClient";
|
|
import presentPin from "./pin";
|
|
import presentPolicies from "./policy";
|
|
import presentProviderConfig from "./providerConfig";
|
|
import presentPublicTeam from "./publicTeam";
|
|
import presentReaction from "./reaction";
|
|
import presentRelationship from "./relationship";
|
|
import presentRevision from "./revision";
|
|
import presentSearchQuery from "./searchQuery";
|
|
import presentShare from "./share";
|
|
import presentStar from "./star";
|
|
import presentSubscription from "./subscription";
|
|
import presentTeam from "./team";
|
|
import presentUser from "./user";
|
|
import presentView from "./view";
|
|
|
|
export {
|
|
presentApiKey,
|
|
presentAttachment,
|
|
presentAuthenticationProvider,
|
|
presentAvailableTeam,
|
|
presentCollection,
|
|
presentComment,
|
|
presentDocument,
|
|
presentEvent,
|
|
presentFileOperation,
|
|
presentGroup,
|
|
presentGroupUser,
|
|
presentGroupMembership,
|
|
presentImport,
|
|
presentIntegration,
|
|
presentMembership,
|
|
presentOAuthClient,
|
|
presentPublishedOAuthClient,
|
|
presentPublicTeam,
|
|
presentPin,
|
|
presentPolicies,
|
|
presentProviderConfig,
|
|
presentReaction,
|
|
presentRelationship,
|
|
presentRevision,
|
|
presentSearchQuery,
|
|
presentShare,
|
|
presentStar,
|
|
presentSubscription,
|
|
presentTeam,
|
|
presentUser,
|
|
presentView,
|
|
};
|