Skip to content

Instantly share code, notes, and snippets.

@phyng
Created July 10, 2017 01:21
Show Gist options
  • Select an option

  • Save phyng/472df1cde8bd0a847d5fe51e99933432 to your computer and use it in GitHub Desktop.

Select an option

Save phyng/472df1cde8bd0a847d5fe51e99933432 to your computer and use it in GitHub Desktop.
ALTER TABLE order_orderitem ADD company_id int;
CREATE INDEX order_orderitem_company_id ON order_orderitem USING btree (company_id);
ALTER TABLE ONLY order_orderitem
ADD CONSTRAINT company_id_refs_id_4459ffbd FOREIGN KEY (company_id) REFERENCES company_company(id) DEFERRABLE INITIALLY DEFERRED;
@phyng
Copy link
Author

phyng commented Jul 10, 2017

                                      Table "public.order_orderitem"
      Column      |          Type          |                          Modifiers                           
------------------+------------------------+--------------------------------------------------------------
 id               | integer                | not null default nextval('order_orderitem_id_seq'::regclass)
 order_id         | integer                | not null
 price            | double precision       | not null default 0
 product_quantity | double precision       | 
 product_name     | character varying(100) | not null
 product_price    | double precision       | not null default 0
 review_yet       | boolean                | not null
 item_type_id     | integer                | 
 item_id          | integer                | 
 company_id       | integer                | not null
 suit_id          | integer                | 
 parent_id        | integer                | 
 is_gift          | boolean                | not null
 extra_setting    | jsonb                  | not null
Indexes:
    "order_orderitem_id_pkey" PRIMARY KEY, btree (id)
    "order_orderitem_company_id" btree (company_id)
    "order_orderitem_item_type_id" btree (item_type_id)
    "order_orderitem_order_id" btree (order_id)
    "order_orderitem_parent_id" btree (parent_id)
    "order_orderitem_suit_id" btree (suit_id)
Check constraints:
    "ck_item_id_pstv_416c3687c672870d" CHECK (item_id >= 0)
    "order_orderitem_item_id_check" CHECK (item_id >= 0)
Foreign-key constraints:
    "company_id_refs_id_4459ffbd" FOREIGN KEY (company_id) REFERENCES company_company(id) DEFERRABLE INITIALLY DEFERRED
    "item_type_id_refs_id_104792d3" FOREIGN KEY (item_type_id) REFERENCES django_content_type(id) DEFERRABLE INITIALLY DEFERRED
    "parent_id_refs_id_62942358" FOREIGN KEY (parent_id) REFERENCES order_orderitem(id) DEFERRABLE INITIALLY DEFERRED
    "suit_id_refs_id_e4272369" FOREIGN KEY (suit_id) REFERENCES store_suit(id) DEFERRABLE INITIALLY DEFERRED
Referenced by:
    TABLE "wysiwyg_forms_formdata" CONSTRAINT "item_id_refs_id_45d128a6" FOREIGN KEY (item_id) REFERENCES order_orderitem(id) DEFERRABLE INITIALLY DEFERRED
    TABLE "lottery_lotteryrecord" CONSTRAINT "item_id_refs_id_b71bca1f" FOREIGN KEY (item_id) REFERENCES order_orderitem(id) DEFERRABLE INITIALLY DEFERRED
    TABLE "order_orderitempropertyvalue" CONSTRAINT "order_item_id_refs_id_4f3b7ad3aaa6a7a4" FOREIGN KEY (order_item_id) REFERENCES order_orderitem(id) DEFERRABLE INITIALLY DEFERRED
    TABLE "booking_bookingitem" CONSTRAINT "order_item_id_refs_id_aa91e82f" FOREIGN KEY (order_item_id) REFERENCES order_orderitem(id) DEFERRABLE INITIALLY DEFERRED
    TABLE "order_orderdata" CONSTRAINT "order_orderdata_order_item_id_bf267a76_fk_order_orderitem_id" FOREIGN KEY (order_item_id) REFERENCES order_orderitem(id) DEFERRABLE INITIALLY DEFERRED
    TABLE "order_orderitem" CONSTRAINT "parent_id_refs_id_62942358" FOREIGN KEY (parent_id) REFERENCES order_orderitem(id) DEFERRABLE INITIALLY DEFERRED
    TABLE "reviews_revieweditem" CONSTRAINT "reviews_reviewedite_orderitem_id_be29fb63_fk_order_orderitem_id" FOREIGN KEY (orderitem_id) REFERENCES order_orderitem(id) DEFERRABLE INITIALLY DEFERRED
    TABLE "store_stockitem" CONSTRAINT "store_stockitem_order_item_id_5f6e3c65_fk_order_orderitem_id" FOREIGN KEY (order_item_id) REFERENCES order_orderitem(id) DEFERRABLE INITIALLY DEFERRED

@phyng
Copy link
Author

phyng commented Jul 10, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment