From 869cbd43e00940612ef970bb5defd7e7e0aaf00c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B9=AF=E6=9C=AC=20=E9=96=8B?= Date: Fri, 8 Mar 2024 05:20:00 +0000 Subject: [PATCH] =?UTF-8?q?Merged=20PR=20810:=20=E3=82=A2=E3=82=AB?= =?UTF-8?q?=E3=82=A6=E3=83=B3=E3=83=88=E9=80=80=E9=81=BF=E3=83=86=E3=83=BC?= =?UTF-8?q?=E3=83=96=E3=83=AB=E4=BD=9C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 概要 [Task3848: アカウント退避テーブル作成](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/3848) - アカウントテーブルと同様の構造をしたアカウント退避テーブルを作成 - ※差分: company_nameを削除、active_worktype_idの外部キー制約を削除 ## レビューポイント - 上記要素以外はaccountsテーブルの要素と同等であるか - 張られたインデックスに不足はないか - 想定と違う構造になっていないか ## 動作確認状況 - npm run migrate:up/downを実施 - EXPLAINでindexが機能していそうな事を確認 ``` EXPLAIN SELECT * FROM omds_ccb.accounts_archive where parent_account_id=1; --------------------------------------------------- # id, select_type, table, partitions, type, possible_keys, key, key_len, ref, rows, filtered, Extra '1', 'SIMPLE', 'accounts_archive', NULL, 'ref', 'idx_accounts_archive_parent_account_id', 'idx_accounts_archive_parent_account_id', '9', 'const', '1', '100.00', NULL ``` ``` EXPLAIN SELECT * FROM omds_ccb.accounts_archive where tier=2; --------------------------------------------------- # id, select_type, table, partitions, type, possible_keys, key, key_len, ref, rows, filtered, Extra '1', 'SIMPLE', 'accounts_archive', NULL, 'ref', 'idx_accounts_archive_tier', 'idx_accounts_archive_tier', '4', 'const', '2', '100.00', NULL ``` ``` EXPLAIN SELECT * FROM omds_ccb.accounts_archive where parent_account_id=1 AND tier=1; ---------------------------------------------------- # id, select_type, table, partitions, type, possible_keys, key, key_len, ref, rows, filtered, Extra '1', 'SIMPLE', 'accounts_archive', NULL, 'ref', 'idx_accounts_archive_parent_account_id,idx_accounts_archive_tier', 'idx_accounts_archive_parent_account_id', '9', 'const', '1', '50.00', 'Using where' ``` --- .../060-create_accounts_archive.sql | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 dictation_server/db/migrations/060-create_accounts_archive.sql diff --git a/dictation_server/db/migrations/060-create_accounts_archive.sql b/dictation_server/db/migrations/060-create_accounts_archive.sql new file mode 100644 index 0000000..e6e8f57 --- /dev/null +++ b/dictation_server/db/migrations/060-create_accounts_archive.sql @@ -0,0 +1,24 @@ +-- +migrate Up +CREATE TABLE IF NOT EXISTS `accounts_archive` ( + `id` BIGINT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY COMMENT 'ID', + `parent_account_id` BIGINT UNSIGNED COMMENT '親アカウントID', + `tier` INT UNSIGNED NOT NULL COMMENT '商流における階層', + `country` VARCHAR(16) NOT NULL COMMENT '国名(ISO 3166-1 alpha-2)', + `delegation_permission` BOOLEAN NOT NULL DEFAULT 0 COMMENT '上位階層からの代行操作を許可しているか', + `locked` BOOLEAN NOT NULL DEFAULT 0 COMMENT 'アカウントがロック済みであるか', + `verified` BOOLEAN NOT NULL DEFAULT 0 COMMENT 'email認証が完了済みであるか', + `primary_admin_user_id` BIGINT UNSIGNED COMMENT 'プライマリ管理者ユーザーID', + `secondary_admin_user_id` BIGINT UNSIGNED COMMENT 'セカンダリ管理者ユーザーID', + `active_worktype_id` BIGINT UNSIGNED COMMENT 'アカウントで利用するデフォルトのWorkTypeID(Active WorktypeID)の内部ID', + `auto_file_delete` BOOLEAN NOT NULL DEFAULT 0 COMMENT '自動ファイル削除をするかどうか', + `file_retention_days` INT UNSIGNED COMMENT '文字起こし完了してから自動ファイル削除するまでのファイル保持日数', + `deleted_at` TIMESTAMP COMMENT '削除時刻', + `created_by` VARCHAR(255) COMMENT '作成者', + `created_at` TIMESTAMP DEFAULT now() COMMENT '作成時刻', + `updated_by` VARCHAR(255) COMMENT '更新者', + `updated_at` TIMESTAMP DEFAULT now() COMMENT '更新時刻', + INDEX `idx_accounts_archive_tier` (`tier`) +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci; + +-- +migrate Down +DROP TABLE `accounts_archive`; \ No newline at end of file