· 8 years ago · Jan 27, 2018, 04:44 AM
1
2
3drop table if exists product_category cascade;
4drop SEQUENCE product_category_id_seq;
5drop table if exists product cascade;
6drop SEQUENCE product_id_seq;
7
8CREATE SEQUENCE product_category_id_seq
9 START WITH 1
10 INCREMENT BY 1
11 NO MINVALUE
12 NO MAXVALUE
13 CACHE 1;
14
15CREATE SEQUENCE product_id_seq
16 START WITH 1
17 INCREMENT BY 1
18 NO MINVALUE
19 NO MAXVALUE
20 CACHE 1;
21
22
23CREATE TABLE product_category (
24 id bigint NOT NULL DEFAULT nextval('product_category_id_seq'::regclass) ,
25 parent_id bigint,
26 code varchar(50),
27 name character varying(255),
28 creation_date timestamp without time zone DEFAULT now() NOT NULL
29);
30
31CREATE TABLE product (
32 id bigint NOT NULL DEFAULT nextval('product_id_seq'::regclass) ,
33 category_id bigint,
34 code varchar(50),
35 name character varying(255),
36 creation_date timestamp without time zone DEFAULT now() NOT NULL
37);