Merged PR 896: バージョンアップ用SQLを作成

## 概要
[Task4044: バージョンアップ用SQLを作成](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/4044)

- jobNumberの初期値を設定するマイグレーションファイル作成
  - タスクテーブルにレコードがある(=タスクを作成したことがある)アカウントに対しては最新のJobNumberで初期値をセットする
  - タスクテーブルにレコードがない(=タスク作成をしたことがない)アカウントに対しては`00000000`をセットする

## レビューポイント
- セットする初期値は認識あっているか
- migrate downの処理は問題ないか

## 動作確認状況
- ローカルで確認、develop環境で確認など
- 行った修正がデグレを発生させていないことを確認できるか
  - 具体的にどのような確認をしたか
    - マイグレーションファイルの作成のみなのでほかに影響はない想定

## 補足
- 相談、参考資料などがあれば
This commit is contained in:
saito.k 2024-05-15 06:15:22 +00:00
parent fe5e8b8e1c
commit 0cca61517c
2 changed files with 19 additions and 1 deletions

View File

@ -0,0 +1,19 @@
-- +migrate Up
INSERT INTO job_number (account_id, job_number)
SELECT
a.id AS account_id,
COALESCE(t.max_job_number, '00000000') AS job_number
FROM
accounts a
LEFT JOIN (
SELECT
account_id,
MAX(job_number) AS max_job_number
FROM
tasks
GROUP BY
account_id
) t ON a.id = t.account_id;
-- +migrate Down
TRUNCATE TABLE job_number;

View File

@ -346,7 +346,6 @@ export const STORAGE_WARNING_THRESHOLD_PERCENT = 80;
*/
export const INITIAL_JOB_NUMBER = '00000000';
/**
* JobNumberの最大値
* @const {string}