Skip to content

Instantly share code, notes, and snippets.

@kiy0taka
Last active September 15, 2017 07:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kiy0taka/91718c9ae59c098fec573b9bd1644db4 to your computer and use it in GitHub Desktop.
Save kiy0taka/91718c9ae59c098fec573b9bd1644db4 to your computer and use it in GitHub Desktop.
論理削除問題

論理削除問題

del_flgを使用しているテーブル

  • dtb_category
  • dtb_class_category
  • dtb_class_name
  • dtb_customer
  • dtb_customer_address
  • dtb_customer_favorite_product
  • dtb_delivery
  • dtb_mail_template
  • dtb_member
  • dtb_news
  • dtb_order
  • dtb_payment
  • dtb_plugin
  • dtb_plugin_event_handler
  • dtb_product
  • dtb_product_class
  • dtb_shipping
  • dtb_tax_rule

対応方法

物理削除だけ対応

テーブル名 備考 PR
dtb_customer_address 元から物理削除している #2490
dtb_customer_favorite_product 元から物理削除している #2490
dtb_mail_template dtb_mail_historyの参照制約を外す #2490
dtb_news FK制約がないため物理削除 #2490
dtb_plugin dtb_plugin_event_handlerとのFK制約のみ #2490
dtb_plugin_event_handler dtb_pluginにカスケードされる #2490
dtb_tax_rule FK制約がないがないため物理削除 #2490
dtb_category #2492

表示/非表示をvisibleプロパティで対応

テーブル名 PR
dtb_class_category #2492
dtb_class_name #2504
dtb_product_class #2506
dtb_delivery #2491
dtb_payment #2499
  • 非表示の場合
    • フロント側には出てこない
    • 管理画面では表示される
/**
 * @var boolean
 *
 * @ORM\Column(name="visible", type="boolean", options={"default":true})
 */
private $visible;

/**
 * @return boolean
 */
public function isVisible()
{
    return $this->visible;
}

/**
 * @param boolean $visible
 * @return Payment
 */
public function setVisible($visible)
{
    $this->visible = $visible;
    return $this;
}

既存のステータスを利用

テーブル名 ステータステーブル名 ステータス値 PR
dtb_member mtb_work 非稼働 #2496
dtb_order mtb_order_status キャンセル #2502

既存のステータスに新しい値を追加

テーブル名 ステータステーブル名 ステータス値 PR
dtb_customer mtb_customer_status 退会 #2501
dtb_product mtb_disp 廃止 #2503

新しくステータスそのものを追加する

テーブル名 ステータステーブル名 ステータス値 PR
dtb_shipping mtb_shipping_status 出荷準備中/出荷済み/キャンセル #2502
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment