Merged PR 712: 行ロック横展開2
## 概要 [Task3470: 行ロック横展開2](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/3470) 以下のリポジトリの各メソッドについてロックを追加し、必要なインデックスを追加するマイグレーションファイルを追加しました。 - licenses - order - 注文の取得にロックを追加して同じPO番号をチェックできるようにする - createCardLicenses - ライセンスキーチェック毎にロックを追加して同じライセンスキーをチェックできるようにする - activateCardLicense - ライセンスキーのチェックにロックを追加して同一のライセンスキーがアクティベート済みかチェックできるようにする - issueLicense - 注文のチェックにロックを追加して同一の注文に対して複数回ライセンスが発行されないようにする - allocateLicense - ユーザーのライセンス状態取得にロックを追加して複数回割り当てできないようにする - deallocateLicense - ユーザーのライセンス状態取得にロックを追加して複数回解除できないようにする - cancelOrder - 注文のチェックにロックを追加してキャンセル中にライセンスが発行されないようにする ※こちらの資料を参考に各メソッド内で影響に関連すると思われるselectにロックを追加しています。 [行ロックに関する影響調査.xlsx](https://ndstokyo.sharepoint.com/❌/r/sites/Piranha/Shared%20Documents/General/OMDS/%E8%A1%8C%E3%83%AD%E3%83%83%E3%82%AF%E3%81%AB%E9%96%A2%E3%81%99%E3%82%8B%E5%BD%B1%E9%9F%BF%E8%AA%BF%E6%9F%BB.xlsx?d=wdd6f3d97f7b04a538095c459f8eee2eb&csf=1&web=1&e=qASAOx) 上記資料を参考にタスク内で担当するメソッドについてロックの対応箇所を整理しました。 [Task3470](https://ndstokyo.sharepoint.com/:f:/r/sites/Piranha/Shared%20Documents/General/%E3%83%A9%E3%82%A4%E3%82%BB%E3%83%B3%E3%82%B9%E3%83%9D%E3%83%BC%E3%82%BF%E3%83%AB/%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%BC%E3%83%B3%E3%82%B7%E3%83%A7%E3%83%83%E3%83%88/Task3470?csf=1&web=1&e=OGnOhp) ## レビューポイント - 各メソッドの対応方針は適切でしょうか? ## UIの変更 - なし ## 動作確認状況 - ローカルで確認
This commit is contained in:
parent
f9d5082f39
commit
6d6eee91e0
13
dictation_server/db/migrations/054-add_license_index.sql
Normal file
13
dictation_server/db/migrations/054-add_license_index.sql
Normal file
@ -0,0 +1,13 @@
|
||||
-- +migrate Up
|
||||
ALTER TABLE `license_orders` ADD INDEX `idx_po_number` (po_number);
|
||||
ALTER TABLE `license_orders` ADD INDEX `idx_from_account_id` (from_account_id);
|
||||
ALTER TABLE `license_orders` ADD INDEX `idx_status` (status);
|
||||
ALTER TABLE `card_licenses` ADD INDEX `idx_card_license_key` (card_license_key);
|
||||
ALTER TABLE `licenses` ADD INDEX `idx_status` (status);
|
||||
|
||||
-- +migrate Down
|
||||
ALTER TABLE `license_orders` DROP INDEX `idx_po_number`;
|
||||
ALTER TABLE `license_orders` DROP INDEX `idx_from_account_id`;
|
||||
ALTER TABLE `license_orders` DROP INDEX `idx_status`;
|
||||
ALTER TABLE `card_licenses` DROP INDEX `idx_card_license_key`;
|
||||
ALTER TABLE `licenses` DROP INDEX `idx_status`;
|
||||
@ -81,6 +81,7 @@ export class LicensesRepositoryService {
|
||||
},
|
||||
],
|
||||
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||
lock: { mode: 'pessimistic_write' },
|
||||
});
|
||||
// 重複があった場合はエラーを返却する
|
||||
if (isPoNumberDuplicated) {
|
||||
@ -193,6 +194,7 @@ export class LicensesRepositoryService {
|
||||
card_license_key: In(generateKeys),
|
||||
},
|
||||
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||
lock: { mode: 'pessimistic_write' },
|
||||
});
|
||||
if (existingCardLicenses.length > 0) {
|
||||
// 重複分を配列から削除
|
||||
@ -292,6 +294,7 @@ export class LicensesRepositoryService {
|
||||
card_license_key: licenseKey,
|
||||
},
|
||||
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||
lock: { mode: 'pessimistic_write' },
|
||||
});
|
||||
// カードライセンスが存在しなければエラー
|
||||
if (!targetCardLicense) {
|
||||
@ -602,6 +605,7 @@ export class LicensesRepositoryService {
|
||||
allocated_user_id: userId,
|
||||
},
|
||||
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||
lock: { mode: 'pessimistic_write' },
|
||||
});
|
||||
|
||||
// 既にライセンスが割り当てられているなら、割り当てを解除
|
||||
@ -717,6 +721,7 @@ export class LicensesRepositoryService {
|
||||
status: LICENSE_ALLOCATED_STATUS.ALLOCATED,
|
||||
},
|
||||
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||
lock: { mode: 'pessimistic_write' },
|
||||
});
|
||||
|
||||
// ライセンスが割り当てられていない場合はエラー
|
||||
@ -776,6 +781,7 @@ export class LicensesRepositoryService {
|
||||
status: LICENSE_ISSUE_STATUS.ISSUE_REQUESTING,
|
||||
},
|
||||
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||
lock: { mode: 'pessimistic_write' },
|
||||
});
|
||||
|
||||
// キャンセル対象の注文が存在しない場合エラー
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user