CREATE TABLE ikl_application (
    "id" SERIAL primary key,
    "name" varchar(20) not null,
    "ipaddress" varchar(20) not null,
    "key" varchar(50) not null,
    "updated" timestamp ,
    "created" timestamp default current_timestamp not null
);


CREATE TABLE ikl_member (
    "id" SERIAL primary key,
    "application_id" int not null,
    "member_invited_id" int not null,
    "identifier" varchar(20) not null,
    "point" int default 0 not null,
    "updated" timestamp ,
    "created" timestamp default current_timestamp not null
);

CREATE TABLE ikl_voucher (
    "id" SERIAL primary key,
    "title" varchar(10) not null,
    "image" varchar(100) not null,
    "description" text,
    "sell_status" bool not null,
    "point_price" int not null,
    "given_status" bool not null,
    "given_condition" varchar(50) not null,
    "given_duration" bool not null,
    "given_duration_day" int,
    "valid_before" timestamp,
    "voucher_status" varchar(10) not null,
    "maximum_owned" int not null,
    "updated" timestamp ,
    "created" timestamp default current_timestamp not null
);


CREATE TABLE ikl_member_voucher (
    "id" SERIAL primary key,
    "member_id" int not null,
    "voucher_id" int not null,
    "member_voucher_status" varchar(10) not null,
    "remaining_time" int,
    "updated" timestamp ,
    "created" timestamp default current_timestamp not null
);

create table ikl_member_transaction (
	"id" SERIAL primary key,
    "member_id" int not null,
    "voucher_counting" json not null,
    "additionalinfo" varchar(10),
    "updated" timestamp ,
    "created" timestamp default current_timestamp not null
);