# リスト共有DB設計 ## 追加するテーブル 各ユーザーDBに以下のテーブルを1つ追加 テーブル名: list_share | カラム名 | 型 | その他 | DBに残すコメント | | ----------- | ------- | --- | --- | | list_share_id | int(11) | NULL FALSE | | | list_id | int(11) | NULL FALSE | リストID | | operator_id | int(11) | NULL FALSE | オペレーターID | | support_flag | tinyint(2) | NULL FALSE | 対応済みかどうか(1: 未対応 2: 対応済み) | | comment | text | NULL 許可 | コメント | | make_date | datetime | NULL FALSE | 作成日時 | | support_date | datetime | NULL 許可 | 対応日時 | ※supported_date は対応済みになった時に更新日時を保存する。それまではNULL --- 旧LN リスト共有 ![](https://i.imgur.com/4HqPGsB.png) ## SQL ``` CREATE TABLE `list_share` ( `list_share_id` int(11) NOT NULL AUTO_INCREMENT, `list_id` int(11) unsigned NOT NULL, `operator_id` int(11) unsigned NOT NULL, `support_flag` tinyint(1) NOT NULL COMMENT '対応済みかどうか(0: 未対応 1: 対応済み)', `comment` text DEFAULT NULL COMMENT 'コメント', `make_date` datetime NOT NULL COMMENT '作成日時', `support_date` datetime DEFAULT NULL COMMENT 'サポート日時', `_created_at` datetime NOT NULL DEFAULT current_timestamp() COMMENT '追加日時', `_created_by` int(11) NOT NULL DEFAULT 0 COMMENT '追加メンバーID', `_updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT '更新日時', `_updated_by` int(11) NOT NULL DEFAULT 0 COMMENT '更新メンバーID', PRIMARY KEY (`list_share_id`), INDEX (list_id), FOREIGN KEY (list_id) REFERENCES list (list_id) ON DELETE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=132 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; ```