Skip to content

Commit

Permalink
add unique constraint on ean13 and upc
Browse files Browse the repository at this point in the history
  • Loading branch information
norbertlaposa committed Apr 9, 2021
1 parent 520d534 commit 43167dd
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 4 deletions.
6 changes: 5 additions & 1 deletion models/ecommerce/ecommerce_product_variety.php
Expand Up @@ -2,7 +2,7 @@
/**
* class ecommerce_product_variety
*
* Copyright (c) 2009-2011 Laposa Limited (https://laposa.ie)
* Copyright (c) 2009-2021 Laposa Limited (https://laposa.ie)
* Licensed under the New BSD License. See the file LICENSE.txt for details.
*
*/
Expand Down Expand Up @@ -141,6 +141,8 @@ private function getCreateTableSql() {
modified timestamp(0) without time zone DEFAULT now() NOT NULL,
publish smallint DEFAULT 0 NOT NULL,
display_permission integer NOT NULL DEFAULT 0,
ean13 character varying(255),
upc character varying(255),
condition smallint NOT NULL DEFAULT 0,
wholesale smallint,
reward_points integer,
Expand All @@ -149,6 +151,8 @@ private function getCreateTableSql() {
);
ALTER TABLE ecommerce_product_variety ADD UNIQUE (\"sku\");
ALTER TABLE ecommerce_product_variety ADD UNIQUE (\"ean13\");
ALTER TABLE ecommerce_product_variety ADD UNIQUE (\"upc\");
";

return $sql;
Expand Down
15 changes: 14 additions & 1 deletion project_skeleton/ecommerce_cz.sql
Expand Up @@ -5645,12 +5645,25 @@ ALTER TABLE ONLY ecommerce_product_type
--
-- Name: ecommerce_product_variety_code_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
-- Name: ecommerce_product_variety_sku_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
ALTER TABLE ONLY ecommerce_product_variety
ADD CONSTRAINT ecommerce_product_variety_code_key UNIQUE (sku);
--
-- Name: ecommerce_product_variety_ean13_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
ALTER TABLE ONLY ecommerce_product_variety
ADD CONSTRAINT ecommerce_product_variety_ean13_key UNIQUE (ean13);
--
-- Name: ecommerce_product_variety_upc_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
ALTER TABLE ONLY ecommerce_product_variety
ADD CONSTRAINT ecommerce_product_variety_upc_key UNIQUE (upc);
--
-- Name: ecommerce_product_variety_image_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
Expand Down
17 changes: 15 additions & 2 deletions project_skeleton/ecommerce_uk.sql
Expand Up @@ -5659,12 +5659,25 @@ ALTER TABLE ONLY ecommerce_product_type
--
-- Name: ecommerce_product_variety_code_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
-- Name: ecommerce_product_variety_sku_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
ALTER TABLE ONLY ecommerce_product_variety
ADD CONSTRAINT ecommerce_product_variety_code_key UNIQUE (sku);
ADD CONSTRAINT ecommerce_product_variety_sku_key UNIQUE (sku);
--
-- Name: ecommerce_product_variety_ean13_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
ALTER TABLE ONLY ecommerce_product_variety
ADD CONSTRAINT ecommerce_product_variety_ean13_key UNIQUE (ean13);
--
-- Name: ecommerce_product_variety_upc_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
ALTER TABLE ONLY ecommerce_product_variety
ADD CONSTRAINT ecommerce_product_variety_upc_key UNIQUE (upc);
--
-- Name: ecommerce_product_variety_image_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
Expand Down
2 changes: 2 additions & 0 deletions share/docs/database/DB_8INDEXES.sql
Expand Up @@ -35,6 +35,8 @@ CREATE INDEX ecommerce_product_product_type_id_idx ON ecommerce_product (product
CREATE INDEX ecommerce_product_publish_idx ON ecommerce_product (publish);

CREATE INDEX ecommerce_product_variety_product_id_idx ON ecommerce_product_variety (product_id);
CREATE INDEX ecommerce_product_variety_product_ean13_idx ON ecommerce_product_variety(ean13);
CREATE INDEX ecommerce_product_variety_product_upc_idx ON ecommerce_product_variety(upc);

CREATE INDEX ecommerce_price_product_variety_id_idx ON ecommerce_price (product_variety_id);
CREATE INDEX ecommerce_price_currency_code_idx ON ecommerce_price (currency_code);
Expand Down

0 comments on commit 43167dd

Please sign in to comment.