Commit 9a092018 authored by Cédric Houbart's avatar Cédric Houbart
Browse files

Database for compositions and tariff areas + update scripts

parent 0daa4e5c
......@@ -6,7 +6,7 @@ CREATE TABLE APPLICATIONS (
VERSION VARCHAR(255) NOT NULL,
PRIMARY KEY (ID)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO APPLICATIONS(ID, NAME, VERSION) VALUES("postech", "POS-Tech", "3");
INSERT INTO APPLICATIONS(ID, NAME, VERSION) VALUES("postech", "POS-Tech", "4");
CREATE TABLE ROLES (
ID VARCHAR(255) NOT NULL,
......@@ -206,6 +206,40 @@ CREATE TABLE PRODUCTS_COM (
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE UNIQUE INDEX PCOM_INX_PROD ON PRODUCTS_COM(PRODUCT, PRODUCT2);
CREATE TABLE SUBGROUPS (
ID VARCHAR(255) NOT NULL,
COMPOSITION VARCHAR(255) NOT NULL,
NAME VARCHAR(255) NOT NULL,
IMAGE MEDIUMBLOB,
PRIMARY KEY(ID),
CONSTRAINT SUBGROUPS_FK_1 FOREIGN KEY (COMPOSITION) REFERENCES PRODUCTS(ID) ON DELETE CASCADE
);
CREATE TABLE SUBGROUPS_PROD (
SUBGROUP VARCHAR(255) NOT NULL,
PRODUCT VARCHAR(255) NOT NULL,
PRIMARY KEY (SUBGROUP, PRODUCT),
CONSTRAINT SUBGROUPS_PROD_FK_1 FOREIGN KEY (SUBGROUP) REFERENCES SUBGROUPS(ID) ON DELETE CASCADE,
CONSTRAINT SUBGROUPS_PROD_FK_2 FOREIGN KEY (PRODUCT) REFERENCES PRODUCTS(ID) ON DELETE CASCADE
);
CREATE TABLE TARIFFAREAS (
ID VARCHAR(255) NOT NULL,
NAME VARCHAR(255) NOT NULL,
TARIFFORDER INTEGER DEFAULT 0,
PRIMARY KEY(ID)
);
CREATE UNIQUE INDEX TARIFFAREAS_NAME_INX ON TARIFFAREAS(NAME);
CREATE TABLE TARIFFAREAS_PROD (
TARIFFID VARCHAR(255) NOT NULL,
PRODUCTID VARCHAR(255) NOT NULL,
PRICESELL DOUBLE NOT NULL,
PRIMARY KEY (TARIFFID, PRODUCTID),
CONSTRAINT TARIFFAREAS_PROD_FK_1 FOREIGN KEY (TARIFFID) REFERENCES TARIFFAREAS(ID) ON DELETE CASCADE,
CONSTRAINT TARIFFAREAS_PROD_FK_2 FOREIGN KEY (PRODUCTID) REFERENCES PRODUCTS(ID) ON DELETE CASCADE
);
CREATE TABLE LOCATIONS (
ID VARCHAR(255) NOT NULL,
NAME VARCHAR(255) NOT NULL,
......@@ -281,10 +315,12 @@ CREATE TABLE TICKETS (
CUSTOMER VARCHAR(255),
STATUS INTEGER DEFAULT 0 NOT NULL,
CUSTCOUNT INTEGER NULL,
TARIFFAREA VARCHAR(255) DEFAULT NULL,
PRIMARY KEY (ID),
CONSTRAINT TICKETS_FK_ID FOREIGN KEY (ID) REFERENCES RECEIPTS(ID),
CONSTRAINT TICKETS_FK_2 FOREIGN KEY (PERSON) REFERENCES PEOPLE(ID),
CONSTRAINT TICKETS_CUSTOMERS_FK FOREIGN KEY (CUSTOMER) REFERENCES CUSTOMERS(ID)
CONSTRAINT TICKETS_CUSTOMERS_FK FOREIGN KEY (CUSTOMER) REFERENCES CUSTOMERS(ID),
CONSTRAINT TICKETS_TARIFFAREA FOREIGN KEY (TARIFFAREA) REFERENCES TARIFFAREAS(ID)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE INDEX TICKETS_TICKETID ON TICKETS(TICKETTYPE, TICKETID);
......
-- France default data
INSERT INTO CATEGORIES(ID, NAME) VALUES ('000', 'Categorie standard');
INSERT INTO CATEGORIES(ID, NAME) VALUES ('0', 'Formules');
INSERT INTO LOCATIONS(ID, NAME,ADDRESS) VALUES('0', 'Principal', NULL);
-- Taxes
......
-- France default data
INSERT INTO CATEGORIES(ID, NAME) VALUES ('000', 'Categorie standard');
INSERT INTO CATEGORIES(ID, NAME) VALUES ('0', 'Formules');
INSERT INTO LOCATIONS(ID, NAME,ADDRESS) VALUES('0', 'Principal', NULL);
-- Taxes
......
-- France default data
INSERT INTO CATEGORIES(ID, NAME) VALUES ('000', 'Categorie standard');
INSERT INTO CATEGORIES(ID, NAME) VALUES ('0', 'Formules');
INSERT INTO LOCATIONS(ID, NAME,ADDRESS) VALUES('0', 'Principal', NULL);
-- Taxes
......
-- POS-tech is a point of sales software
-- Copyright (C) 2012 SARL SCOP Scil
-- http://trac.scil.coop/pos-tech
--
-- This file is part of POS-Tech
--
-- POS-tech is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- POS-tech is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with POS-tech. If not, see <http://www.gnu.org/licenses/>.
-- Database upgrade script for MYSQL
-- db v1 - v2
-- final script
ALTER TABLE PRODUCTS DROP INDEX PRODUCTS_INX_1;
ALTER TABLE PRODUCTS MODIFY PRICEBUY double;
ALTER TABLE CLOSEDCASH MODIFY DATESTART datetime;
UPDATE APPLICATIONS SET VERSION = 2 WHERE ID = "postech";
-- POS-tech is a point of sales software
-- Copyright (C) 2012 SARL SCOP Scil
-- http://trac.scil.coop/pos-tech
--
-- This file is part of POS-Tech
--
-- POS-tech is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- POS-tech is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with POS-tech. If not, see <http://www.gnu.org/licenses/>.
-- Database upgrade script for MYSQL
-- db v2 - v3
-- final script
ALTER TABLE PRODUCTS ADD COLUMN DISCOUNTENABLED BIT DEFAULT b'0' NOT NULL;
ALTER TABLE PRODUCTS ADD COLUMN DISCOUNTRATE DOUBLE DEFAULT 0.0 NOT NULL;
ALTER TABLE TICKETS ADD COLUMN CUSTCOUNT INTEGER DEFAULT NULL NULL;
UPDATE APPLICATIONS SET VERSION = 3 WHERE ID = "postech";
-- POS-tech is a point of sales software
-- Copyright (C) 2012 SARL SCOP Scil
-- http://trac.scil.coop/pos-tech
--
-- This file is part of POS-Tech
--
-- POS-tech is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- POS-tech is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with POS-tech. If not, see <http://www.gnu.org/licenses/>.
-- Database upgrade script for MYSQL
-- db v3 - v4
-- final script
CREATE TABLE SUBGROUPS (
ID VARCHAR(255) NOT NULL,
COMPOSITION VARCHAR(255) NOT NULL,
NAME VARCHAR(255) NOT NULL,
IMAGE MEDIUMBLOB,
PRIMARY KEY(ID),
CONSTRAINT SUBGROUPS_FK_1 FOREIGN KEY (COMPOSITION) REFERENCES PRODUCTS(ID) ON DELETE CASCADE
);
CREATE TABLE SUBGROUPS_PROD (
SUBGROUP VARCHAR(255) NOT NULL,
PRODUCT VARCHAR(255) NOT NULL,
PRIMARY KEY (SUBGROUP, PRODUCT),
CONSTRAINT SUBGROUPS_PROD_FK_1 FOREIGN KEY (SUBGROUP) REFERENCES SUBGROUPS(ID) ON DELETE CASCADE,
CONSTRAINT SUBGROUPS_PROD_FK_2 FOREIGN KEY (PRODUCT) REFERENCES PRODUCTS(ID) ON DELETE CASCADE
);
INSERT INTO CATEGORIES(ID, NAME) VALUES ('0', 'Formules');
CREATE TABLE TARIFFAREAS (
ID VARCHAR(255) NOT NULL,
NAME VARCHAR(255) NOT NULL,
TARIFFORDER INTEGER DEFAULT 0,
PRIMARY KEY(ID)
);
CREATE UNIQUE INDEX TARIFFAREAS_NAME_INX ON TARIFFAREAS(NAME);
CREATE TABLE TARIFFAREAS_PROD (
TARIFFID VARCHAR(255) NOT NULL,
PRODUCTID VARCHAR(255) NOT NULL,
PRICESELL DOUBLE NOT NULL,
PRIMARY KEY (TARIFFID, PRODUCTID),
CONSTRAINT TARIFFAREAS_PROD_FK_1 FOREIGN KEY (TARIFFID) REFERENCES TARIFFAREAS(ID) ON DELETE CASCADE,
CONSTRAINT TARIFFAREAS_PROD_FK_2 FOREIGN KEY (PRODUCTID) REFERENCES PRODUCTS(ID) ON DELETE CASCADE
);
ALTER TABLE TICKETS ADD COLUMN TARIFFAREA VARCHAR(255) DEFAULT NULL;
ALTER TABLE TICKETS ADD CONSTRAINT TICKETS_TARIFFAREA FOREIGN KEY (TARIFFAREA) REFERENCES TARIFFAREAS(ID);
UPDATE APPLICATIONS SET VERSION = 4 WHERE ID = "postech";
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment