--
--  商品登録依頼
--      t_pre_item_attr
--

-- DROP TABLE t_pre_item_attr;

CREATE TABLE t_pre_item_attr
(
-- basic
    preitemcd           serial NOT NULL,            -- PriKey
    itemnm              character varying(256),
    itemnmkana          character varying(256),
    itemexp             varchar(4000),

    basic_option01          varchar(1024),
    basic_option02          varchar(1024),
    basic_option03          varchar(1024),
    basic_option04          varchar(1024),
    basic_option05          varchar(1024),
    basic_option06          varchar(1024),
    basic_option07          varchar(1024),
    basic_option08          varchar(1024),
    basic_option09          varchar(1024),
    basic_option10          varchar(1024),

-- struct
    variationnm     character varying(256),
    makeritemcd     character varying(256),
    jancd           character varying(256),
    salestartdate   date,
    orderclosedate  date,
    comment         character varying(1024),

    struct_option01        varchar(1024),
    struct_option02        varchar(1024),
    struct_option03        varchar(1024),
    struct_option04        varchar(1024),
    struct_option05        varchar(1024),
    struct_option06        varchar(1024),
    struct_option07        varchar(1024),
    struct_option08        varchar(1024),
    struct_option09        varchar(1024),
    struct_option10        varchar(1024),
    
-- web
    ReleaseDate date,
    web_Comment character varying(1024),
    
-- seller
    sellercd        integer,                -- ForKey

-- download
    download        integer,      -- 0: 通常商品, 1: ダウンロード商品

-- 
    delflg          boolean,
    adddate         timestamp without time zone,
    upddate         timestamp without time zone,
    updusrnm        character varying(60),
    updpcnm         character varying(60),
    updcnt          integer,

    PRIMARY KEY(preitemcd)
);

-- シリアル初期値
SELECT setval('t_pre_item_attr_preitemcd_seq', 100000);

-- 
-- トリガ
-- 

-- DROP TRIGGER trigger_master_stamp ON t_pre_item_attr;

CREATE TRIGGER trigger_master_stamp
  BEFORE INSERT OR UPDATE
  ON t_pre_item_attr
  FOR EACH ROW
  EXECUTE PROCEDURE g_master_stamp();