<?xml version="1.0"?>

<data>
	<tables-sql><![CDATA[create table CDiscountCAccountGroupRel (
	mvccVersion LONG default 0 not null,
	CDiscountCAccountGroupRelId LONG not null primary key,
	companyId LONG,
	userId LONG,
	userName VARCHAR(75) null,
	createDate DATE null,
	modifiedDate DATE null,
	commerceDiscountId LONG,
	commerceAccountGroupId LONG
);

create table CommerceDiscount (
	mvccVersion LONG default 0 not null,
	uuid_ VARCHAR(75) null,
	externalReferenceCode VARCHAR(75) null,
	commerceDiscountId LONG not null primary key,
	companyId LONG,
	userId LONG,
	userName VARCHAR(75) null,
	createDate DATE null,
	modifiedDate DATE null,
	title VARCHAR(75) null,
	target VARCHAR(75) null,
	useCouponCode BOOLEAN,
	couponCode VARCHAR(75) null,
	usePercentage BOOLEAN,
	maximumDiscountAmount BIGDECIMAL null,
	levelType VARCHAR(75) null,
	level1 BIGDECIMAL null,
	level2 BIGDECIMAL null,
	level3 BIGDECIMAL null,
	level4 BIGDECIMAL null,
	limitationType VARCHAR(75) null,
	limitationTimes INTEGER,
	limitationTimesPerAccount INTEGER,
	numberOfUse INTEGER,
	rulesConjunction BOOLEAN,
	active_ BOOLEAN,
	displayDate DATE null,
	expirationDate DATE null,
	lastPublishDate DATE null,
	status INTEGER,
	statusByUserId LONG,
	statusByUserName VARCHAR(75) null,
	statusDate DATE null
);

create table CommerceDiscountAccountRel (
	mvccVersion LONG default 0 not null,
	uuid_ VARCHAR(75) null,
	commerceDiscountAccountRelId LONG not null primary key,
	companyId LONG,
	userId LONG,
	userName VARCHAR(75) null,
	createDate DATE null,
	modifiedDate DATE null,
	commerceAccountId LONG,
	commerceDiscountId LONG,
	order_ INTEGER,
	lastPublishDate DATE null
);

create table CommerceDiscountOrderTypeRel (
	mvccVersion LONG default 0 not null,
	uuid_ VARCHAR(75) null,
	commerceDiscountOrderTypeRelId LONG not null primary key,
	companyId LONG,
	userId LONG,
	userName VARCHAR(75) null,
	createDate DATE null,
	modifiedDate DATE null,
	commerceDiscountId LONG,
	commerceOrderTypeId LONG,
	priority INTEGER,
	lastPublishDate DATE null
);

create table CommerceDiscountRel (
	mvccVersion LONG default 0 not null,
	commerceDiscountRelId LONG not null primary key,
	companyId LONG,
	userId LONG,
	userName VARCHAR(75) null,
	createDate DATE null,
	modifiedDate DATE null,
	commerceDiscountId LONG,
	classNameId LONG,
	classPK LONG,
	typeSettings TEXT null
);

create table CommerceDiscountRule (
	mvccVersion LONG default 0 not null,
	commerceDiscountRuleId LONG not null primary key,
	companyId LONG,
	userId LONG,
	userName VARCHAR(75) null,
	createDate DATE null,
	modifiedDate DATE null,
	name VARCHAR(75) null,
	commerceDiscountId LONG,
	type_ VARCHAR(75) null,
	typeSettings TEXT null
);

create table CommerceDiscountUsageEntry (
	mvccVersion LONG default 0 not null,
	commerceDiscountUsageEntryId LONG not null primary key,
	companyId LONG,
	userId LONG,
	userName VARCHAR(75) null,
	createDate DATE null,
	modifiedDate DATE null,
	commerceAccountId LONG,
	commerceOrderId LONG,
	commerceDiscountId LONG
);]]></tables-sql>
	<sequences-sql><![CDATA[]]></sequences-sql>
	<indexes-sql><![CDATA[create index IX_F7FFBCCA on CDiscountCAccountGroupRel (commerceAccountGroupId);
create unique index IX_9D768AF5 on CDiscountCAccountGroupRel (commerceDiscountId, commerceAccountGroupId);

create index IX_A7A710FC on CommerceDiscount (companyId, couponCode[$COLUMN_LENGTH:75$], active_);
create unique index IX_D294CDB7 on CommerceDiscount (companyId, externalReferenceCode[$COLUMN_LENGTH:75$]);
create index IX_1CCF5211 on CommerceDiscount (companyId, status, active_, levelType[$COLUMN_LENGTH:75$]);
create index IX_52CB3DB8 on CommerceDiscount (status, displayDate);
create index IX_DE0C3C39 on CommerceDiscount (status, expirationDate);
create index IX_F1A4C552 on CommerceDiscount (uuid_[$COLUMN_LENGTH:75$]);

create unique index IX_E082887A on CommerceDiscountAccountRel (commerceAccountId, commerceDiscountId);
create index IX_6EA2AA99 on CommerceDiscountAccountRel (commerceDiscountId);
create index IX_CEE71686 on CommerceDiscountAccountRel (uuid_[$COLUMN_LENGTH:75$]);

create unique index IX_614617A on CommerceDiscountOrderTypeRel (commerceDiscountId, commerceOrderTypeId);
create index IX_707E0345 on CommerceDiscountOrderTypeRel (commerceOrderTypeId);
create index IX_CEE22E81 on CommerceDiscountOrderTypeRel (uuid_[$COLUMN_LENGTH:75$]);

create index IX_6B4EEC38 on CommerceDiscountRel (classNameId, classPK);
create index IX_DDFDEF40 on CommerceDiscountRel (commerceDiscountId, classNameId);

create index IX_CB9E6769 on CommerceDiscountRule (commerceDiscountId);

create index IX_28CE20FF on CommerceDiscountUsageEntry (commerceDiscountId, commerceAccountId, commerceOrderId);
create index IX_E40C6220 on CommerceDiscountUsageEntry (commerceDiscountId, commerceOrderId);]]></indexes-sql>
</data>