Notion -> Linear移行方法とTips
はじめに
こちらはe-dash advent calendar 2025の22日目の記事です。
こんにちは!e-dashでエンジニアをしている石田です。
先週は、👇の記事でLinearの魅力を存分にお伝えできたかと思います。
この記事では、NotionのタスクやProjectをLinearに移行することになった人が楽に移行できるように、
- 全体像と移行の流れ
- やったこと・やらなかったこと
- 各流れでのポイント・注意点
といった内容を記載します。
対象読者
- Notion -> Linearに移行担当になったEngineer
- 何が移行できて、何が移行できないのか、を知りたい人
※CLI全般の話は本記事では扱いません。
全体像と移行の流れ
まずは前提情報として、弊社のNotionのDatabase構造は、
EPIC > Product Backlog > タスク の3階層になっておりました。
また、このDatabaseを利用してタスク管理していたチームが2チームあり、当然ながら日々タスクは変更されていく状態です。
直近のBacklog、タスクだけでも大量のデータがあり、手作業では不可能でした。
Linearに移行することを決定してから、2週間後のSprint開始日を移行完了の目処として進めました。
移行実行までの流れは、大きく以下です。
- 事前調査(移行対象の整理および検証)
- CLI作成
- 事前練習
- 本番実行
やったこと・やらなかったこと
やったこと
①事前調査(移行対象の整理および検証)
事前調査では、移行できるプロパティの整理をしました。
以下に、弊社での対応関係をまとめました。
Product Backlog Database -> Project
| notionのプロパティ名 | notionの型 | linear | 備考 |
|---|---|---|---|
| title | string | name | Notionで必須のプロパティ。Notionのtitleをそのまま使う |
| team | select | teamIds | チーム |
| status | status | statusId | 未着手、進行中、完了 etc. |
| description | Notion のURL |
※ linear・・・ Linear SDKのcreateProjectの引数
タスクDatabase -> issue
| notionのプロパティ名 | notionの型 | linear | 備考 |
|---|---|---|---|
| title | string | title | Notionで必須のプロパティ。Notionのtitleをそのまま使う |
| team | select | teamId | チーム |
| storyPoint | number | estimate | ストーリーポイント |
| status | status | statusId | 未着手、進行中、完了 etc. |
| assignee | people | assigneeId | 担当者 |
| label | select | labelIds | Bug, Feature, QA etc. |
| projectId | Product BacklogのID | ||
| description | Notion のURL |
※ Notionの型は、NotionのDocumentを参照してください。
※ linear・・・ Linear SDKのcreateIssueの引数
Tips: LinearのteamId、assigneeId、labelIdsの引数は、LinearのAPIで事前にID取得が必要です。
つまり、createIssueの実行前に、これらのIDを取得して保持しておく必要があります。
実装サンプル
import { LinearClient } from "@linear/sdk";
const linearClient = new LinearClient({ apiKey: process.env.LINEAR_API_KEY });
const teams = await linearClient.teams();
const labels = await linearClient.issueLabels({
filter: {
team: {
id: {
eq: linearTeamId,
},
},
},
});
const projectsStatuses = await linearClient.projectStatuses();
やらなかったこと
Notionのblockを移行に含める
技術的には可能ですが、現実的には困難なため移行しませんでした。
Notionのblockは、PDF、File、Codeなど様々なtypeで定義されており、
NotionのSDKはJavaScriptのみで、type-safeにこれらを扱うことができません。
これらを無理に移行するのはコストパフォーマンスが悪いと判断し、移行しませんでした。
代わりに、NotionのリンクをLinear側のissueに紐づけることで、blockの内容を参照できるようにしました。
それ以外の独自プロパティなども移行せず、Notionのリンクから参照してもらうようにしました。
一部の型でも移行したい方のは、Notion API blockを参照してください。
移行担当者が知っておくと役立つこと
Notion databaseのID取得方法
NotionのDatabaseがあるページを開いて、
https://www.notion.so/{{sub-domain}}/{{yyyyy}}?v={{xxxxxx}}
となっているので、yyyyyの部分がDatabaseのIDです。
NotionのURL生成方法
各NotionのpageURLは-を空文字で置き換えないと遷移できません(Notionの仕様による制約です)。
const epics = await notionClient.databases.query({
database_id: process.env.NOTION_EPIC_DATABASE_ID,
filter: {
property: "title",
title: {
equals: "Epic",
},
},
});
const epicId = epics[0].id;
const epicPageUrl = `https://www.notion.so/${subDomain}/${epicId.replace(/-/g, "")}`;
Notionのtitleはparse対策が必要
移行実行時に、特殊文字が含まれ、titleがparseできない場合があります。
その場合は、エラーで落とす、Log出力するなどの考慮をしておきましょう。
何が移行できるのか、何が移行できないのか?
Notionのプロパティは様々な型を表現できますが、全てLinearに移行できるわけではありません。プロパティについては各社それぞれですので一概に言えませんが、移行できる・できないプロパティを以下に記載します。
- 移行できる
- タイトル
- チーム
- 担当者
- ステータス
- ラベル
- ストーリーポイント
- 優先度
- ※リレーション先(スプリントなど)
- relation[0].idがスプリントのリレーション先のIDになるので、そのDatabase情報を先に取得してCode上でMapすることでリレーションを維持しながら移行できます。
# notion api response 'スプリント': { id: 'notion%3A%2F%2Ftasks%2Ftask_sprint_relation', type: 'relation', relation: [ {id: string} ], has_more: false },
- 移行できない
- 添付ファイル(e.g. 画像、PDF)
- 外部連携プロパティ(e.g. Github)
- 以下のようにAPIから返ってくるのですが、IDからPRの情報を取得することはできませんでした。
# notion api response GitHubPR: { id: 'fraI', type: 'relation', relation: [ {id: string} ], has_more: false },
linear SDKを見るとより詳細に確認することができます。
linear SDK
// Project作成時の引数
export declare type ProjectCreateInput = {
/** The color of the project. */
color?: Maybe<Scalars["String"]>;
/** The project content as markdown. */
content?: Maybe<Scalars["String"]>;
/** The ID of the issue from which that project is created. */
convertedFromIssueId?: Maybe<Scalars["String"]>;
/** The description for the project. */
description?: Maybe<Scalars["String"]>;
/** The icon of the project. */
icon?: Maybe<Scalars["String"]>;
/** The identifier in UUID v4 format. If none is provided, the backend will generate one. */
id?: Maybe<Scalars["String"]>;
/** [Internal]The identifiers of the project labels associated with this project. */
labelIds?: Maybe<Array<Scalars["String"]>>;
/** The ID of the last template applied to the project. */
lastAppliedTemplateId?: Maybe<Scalars["String"]>;
/** The identifier of the project lead. */
leadId?: Maybe<Scalars["String"]>;
/** The identifiers of the members of this project. */
memberIds?: Maybe<Array<Scalars["String"]>>;
/** The name of the project. */
name: Scalars["String"];
/** The priority of the project. 0 = No priority, 1 = Urgent, 2 = High, 3 = Normal, 4 = Low. */
priority?: Maybe<Scalars["Int"]>;
/** The sort order for the project within shared views, when ordered by priority. */
prioritySortOrder?: Maybe<Scalars["Float"]>;
/** The sort order for the project within shared views. */
sortOrder?: Maybe<Scalars["Float"]>;
/** The planned start date of the project. */
startDate?: Maybe<Scalars["TimelessDate"]>;
/** The resolution of the project's start date. */
startDateResolution?: Maybe<DateResolutionType>;
/** The ID of the project status. */
statusId?: Maybe<Scalars["String"]>;
/** The planned target date of the project. */
targetDate?: Maybe<Scalars["TimelessDate"]>;
/** The resolution of the project's estimated completion date. */
targetDateResolution?: Maybe<DateResolutionType>;
/** The identifiers of the teams this project is associated with. */
teamIds: Array<Scalars["String"]>;
};
// Issue作成時の引数
export declare type IssueCreateInput = {
/** The identifier of the user to assign the issue to. */
assigneeId?: Maybe<Scalars["String"]>;
/** The date when the issue was completed (e.g. if importing from another system). Must be a date in the past and after createdAt date. Cannot be provided with an incompatible workflow state. */
completedAt?: Maybe<Scalars["DateTime"]>;
/** Create issue as a user with the provided name. This option is only available to OAuth applications creating issues in `actor=app` mode. */
createAsUser?: Maybe<Scalars["String"]>;
/** The date when the issue was created (e.g. if importing from another system). Must be a date in the past. If none is provided, the backend will generate the time as now. */
createdAt?: Maybe<Scalars["DateTime"]>;
/** The cycle associated with the issue. */
cycleId?: Maybe<Scalars["String"]>;
/** The issue description in markdown format. */
description?: Maybe<Scalars["String"]>;
/** [Internal] The issue description as a Prosemirror document. */
descriptionData?: Maybe<Scalars["JSON"]>;
/** Provide an external user avatar URL. Can only be used in conjunction with the `createAsUser` options. This option is only available to OAuth applications creating comments in `actor=app` mode. */
displayIconUrl?: Maybe<Scalars["String"]>;
/** The date at which the issue is due. */
dueDate?: Maybe<Scalars["TimelessDate"]>;
/** The estimated complexity of the issue. */
estimate?: Maybe<Scalars["Int"]>;
/** The identifier in UUID v4 format. If none is provided, the backend will generate one. */
id?: Maybe<Scalars["String"]>;
/** The identifiers of the issue labels associated with this ticket. */
labelIds?: Maybe<Array<Scalars["String"]>>;
/** The ID of the last template applied to the issue. */
lastAppliedTemplateId?: Maybe<Scalars["String"]>;
/** The identifier of the parent issue. */
parentId?: Maybe<Scalars["String"]>;
/** Whether the passed sort order should be preserved. */
preserveSortOrderOnCreate?: Maybe<Scalars["Boolean"]>;
/** The priority of the issue. 0 = No priority, 1 = Urgent, 2 = High, 3 = Normal, 4 = Low. */
priority?: Maybe<Scalars["Int"]>;
/** The position of the issue related to other issues, when ordered by priority. */
prioritySortOrder?: Maybe<Scalars["Float"]>;
/** The project associated with the issue. */
projectId?: Maybe<Scalars["String"]>;
/** The project milestone associated with the issue. */
projectMilestoneId?: Maybe<Scalars["String"]>;
/** The comment the issue is referencing. */
referenceCommentId?: Maybe<Scalars["String"]>;
/** [Internal] The timestamp at which an issue will be considered in breach of SLA. */
slaBreachesAt?: Maybe<Scalars["DateTime"]>;
/** [Internal] The timestamp at which the issue's SLA was started. */
slaStartedAt?: Maybe<Scalars["DateTime"]>;
/** The SLA day count type for the issue. Whether SLA should be business days only or calendar days (default). */
slaType?: Maybe<SLADayCountType>;
/** The position of the issue related to other issues. */
sortOrder?: Maybe<Scalars["Float"]>;
/** The comment the issue is created from. */
sourceCommentId?: Maybe<Scalars["String"]>;
/** [Internal] The pull request comment the issue is created from. */
sourcePullRequestCommentId?: Maybe<Scalars["String"]>;
/** The team state of the issue. */
stateId?: Maybe<Scalars["String"]>;
/** The position of the issue in parent's sub-issue list. */
subIssueSortOrder?: Maybe<Scalars["Float"]>;
/** The identifiers of the users subscribing to this ticket. */
subscriberIds?: Maybe<Array<Scalars["String"]>>;
/** The identifier of the team associated with the issue. */
teamId: Scalars["String"];
/** The identifier of a template the issue should be created from. If other values are provided in the input, they will override template values. */
templateId?: Maybe<Scalars["String"]>;
/** The title of the issue. */
title?: Maybe<Scalars["String"]>;
};
最後に
上記のような細かいつまづきポイントはありつつも、事前に練習をしておくことで
移行当日は特に問題なく2チーム分の移行が完了しました。
もしNotionからLinearに移行する際の参考になれば幸いです。
Discussion