From ab618984ebd3f51bffdb9b42de9eb53a31acf7dc Mon Sep 17 00:00:00 2001 From: "oura.a" Date: Fri, 2 Jun 2023 04:34:25 +0000 Subject: [PATCH] =?UTF-8?q?Merged=20PR=20120:=20DB=E3=83=9E=E3=82=A4?= =?UTF-8?q?=E3=82=B0=E3=83=AC=E3=83=BC=E3=82=B7=E3=83=A7=E3=83=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 概要 [Task1839: DBマイグレーション](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/1839) - migrationファイルの追加(ライセンステーブル/ライセンス割り当て履歴テーブル) ## レビューポイント -カラム名などに違和感がないか -NOT NULL制約や型が正しいか ## UIの変更 - なし ## 動作確認状況 - MySQL Workbenchでの確認 DBのマイグレート sql-migrate up -config=db/dbconfig.yml -env=localを実行してテーブルが作成されるのを確認 sql-migrate down -config=db/dbconfig.yml -env=localを実施して巻き戻せることも確認 ## 補足 - licenses.type(ライセンス種別:トライアル/通常/カード) - licenses.status(ライセンス状態:未割当/割り当て済/削除済) - licenses_history.oparation_type(割り当て種別:割り当て/割り当て解除) - licenses_history.exchange_type(ライセンス切り替え種別:なし/トライアル→通常/紙→通常) --- .../db/migrations/008-create_licenses.sql | 15 +++++++++++++++ .../db/migrations/009-create_licenses_history.sql | 12 ++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 dictation_server/db/migrations/008-create_licenses.sql create mode 100644 dictation_server/db/migrations/009-create_licenses_history.sql diff --git a/dictation_server/db/migrations/008-create_licenses.sql b/dictation_server/db/migrations/008-create_licenses.sql new file mode 100644 index 0000000..be359c3 --- /dev/null +++ b/dictation_server/db/migrations/008-create_licenses.sql @@ -0,0 +1,15 @@ +-- +migrate Up +CREATE TABLE IF NOT EXISTS `licenses` ( + `id` BIGINT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY COMMENT 'ライセンスID', + `expiry_date` TIMESTAMP COMMENT '有効期限', + `account_id` BIGINT UNSIGNED NOT NULL COMMENT '所有アカウントID', + `type` VARCHAR(255) NOT NULL COMMENT 'ライセンス種別(トライアル/通常/カード)', + `status` VARCHAR(255) NOT NULL COMMENT 'ライセンス状態(未割当/割り当て済/削除済)', + `allocated_user_id` BIGINT UNSIGNED COMMENT '割り当てユーザID', + `order_id` BIGINT UNSIGNED COMMENT '注文ID', + `deleted_at` TIMESTAMP COMMENT '削除日時', + `delete_order_id` BIGINT UNSIGNED COMMENT '削除注文ID' +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci; + +-- +migrate Down +DROP TABLE `licenses`; \ No newline at end of file diff --git a/dictation_server/db/migrations/009-create_licenses_history.sql b/dictation_server/db/migrations/009-create_licenses_history.sql new file mode 100644 index 0000000..b74c6b6 --- /dev/null +++ b/dictation_server/db/migrations/009-create_licenses_history.sql @@ -0,0 +1,12 @@ +-- +migrate Up +CREATE TABLE IF NOT EXISTS `licenses_history` ( + `id` BIGINT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY COMMENT 'ライセンス履歴ID', + `user_id` BIGINT UNSIGNED NOT NULL COMMENT 'ユーザID', + `license_id` BIGINT UNSIGNED NOT NULL COMMENT 'ライセンスID', + `allocated` BOOLEAN NOT NULL COMMENT '割り当てたか', + `executed_at` TIMESTAMP NOT NULL COMMENT '実施日時', + `exchange_type` VARCHAR(255) NOT NULL COMMENT 'ライセンス切り替え種別(なし/トライアル→通常/紙→通常)' +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci; + +-- +migrate Down +DROP TABLE `licenses_history`; \ No newline at end of file