Skip to content

Commit

Permalink
Create MS SQL and MySQL database scripts #22
Browse files Browse the repository at this point in the history
  • Loading branch information
zaharchenko committed Apr 11, 2019
1 parent 8a53601 commit 6b1f712
Show file tree
Hide file tree
Showing 10 changed files with 236 additions and 8 deletions.
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

buildscript {
ext.cubaVersion = '7.0.0'
ext.cubaVersion = '7.0.4'
repositories {

mavenLocal()
Expand Down Expand Up @@ -167,7 +167,7 @@ configure(coreModule) {
dbName = dbNameParam
dbUser = 'sa'
dbPassword = ''
}
}

task updateDb(dependsOn: assembleDbScripts, description: 'Updates local database', type: CubaDbUpdate) {
dbName = 'emailtemplates'
Expand All @@ -176,7 +176,7 @@ configure(coreModule) {
dbName = dbNameParam
dbUser = 'sa'
dbPassword = ''
}
}
}

configure(webModule) {
Expand Down
93 changes: 93 additions & 0 deletions modules/core/db/init/mssql/10.create-db.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
-- begin EMAILTEMPLATES_PARAMETER_VALUE
create table EMAILTEMPLATES_PARAMETER_VALUE (
ID uniqueidentifier,
VERSION integer not null,
CREATE_TS datetime2,
CREATED_BY varchar(50),
UPDATE_TS datetime2,
UPDATED_BY varchar(50),
DELETE_TS datetime2,
DELETED_BY varchar(50),
--
PARAMETER_TYPE integer not null,
ALIAS varchar(255) not null,
DEFAULT_VALUE varchar(255),
TEMPLATE_PARAMETER_ID uniqueidentifier not null,
--
primary key nonclustered (ID)
)^
-- end EMAILTEMPLATES_PARAMETER_VALUE
-- begin EMAILTEMPLATES_TEMPLATE_GROUP
create table EMAILTEMPLATES_TEMPLATE_GROUP (
ID uniqueidentifier,
VERSION integer not null,
CREATE_TS datetime2,
CREATED_BY varchar(50),
UPDATE_TS datetime2,
UPDATED_BY varchar(50),
DELETE_TS datetime2,
DELETED_BY varchar(50),
--
NAME varchar(255) not null,
--
primary key nonclustered (ID)
)^
-- end EMAILTEMPLATES_TEMPLATE_GROUP
-- begin EMAILTEMPLATES_EMAIL_TEMPLATE
create table EMAILTEMPLATES_EMAIL_TEMPLATE (
ID uniqueidentifier,
VERSION integer not null,
CREATE_TS datetime2,
CREATED_BY varchar(50),
UPDATE_TS datetime2,
UPDATED_BY varchar(50),
DELETE_TS datetime2,
DELETED_BY varchar(50),
DTYPE varchar(100),
--
USE_REPORT_SUBJECT tinyint,
NAME varchar(255) not null,
GROUP_ID uniqueidentifier,
TYPE_ varchar(50) not null,
CODE varchar(255) not null,
FROM_ varchar(255),
TO_ varchar(max),
CC varchar(max),
BCC varchar(max),
SUBJECT varchar(255),
--
-- from emailtemplates$ReportEmailTemplate
EMAIL_BODY_REPORT_ID uniqueidentifier,
--
-- from emailtemplates$JsonEmailTemplate
HTML varchar(max),
REPORT_XML varchar(max),
--
primary key nonclustered (ID)
)^
-- end EMAILTEMPLATES_EMAIL_TEMPLATE
-- begin EMAILTEMPLATES_TEMPLATE_REPORT
create table EMAILTEMPLATES_TEMPLATE_REPORT (
ID uniqueidentifier,
VERSION integer not null,
CREATE_TS datetime2,
CREATED_BY varchar(50),
UPDATE_TS datetime2,
UPDATED_BY varchar(50),
DELETE_TS datetime2,
DELETED_BY varchar(50),
--
NAME varchar(255),
REPORT_ID uniqueidentifier not null,
EMAIL_TEMPLATE_ID uniqueidentifier,
--
primary key nonclustered (ID)
)^
-- end EMAILTEMPLATES_TEMPLATE_REPORT
-- begin EMAILTEMPLATES_EMLTPTE_FDLINK
create table EMAILTEMPLATES_EMLTPTE_FDLINK (
EMAIL_TEMPLATE_ID uniqueidentifier,
FILE_DESCRIPTOR_ID uniqueidentifier,
primary key (EMAIL_TEMPLATE_ID, FILE_DESCRIPTOR_ID)
)^
-- end EMAILTEMPLATES_EMLTPTE_FDLINK
20 changes: 20 additions & 0 deletions modules/core/db/init/mssql/20.create-db.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
-- begin EMAILTEMPLATES_PARAMETER_VALUE
alter table EMAILTEMPLATES_PARAMETER_VALUE add constraint FK_EMAILTEMPLATES_PARAMETER_VALUE_TEMPLATE_PARAMETER foreign key (TEMPLATE_PARAMETER_ID) references EMAILTEMPLATES_TEMPLATE_REPORT(ID)^
create index IDX_EMAILTEMPLATES_PARAMETER_VALUE_TEMPLATE_PARAMETER on EMAILTEMPLATES_PARAMETER_VALUE (TEMPLATE_PARAMETER_ID)^
-- end EMAILTEMPLATES_PARAMETER_VALUE
-- begin EMAILTEMPLATES_EMAIL_TEMPLATE
alter table EMAILTEMPLATES_EMAIL_TEMPLATE add constraint FK_EMAILTEMPLATES_EMAIL_TEMPLATE_GROUP foreign key (GROUP_ID) references EMAILTEMPLATES_TEMPLATE_GROUP(ID)^
alter table EMAILTEMPLATES_EMAIL_TEMPLATE add constraint FK_EMAILTEMPLATES_EMAIL_TEMPLATE_EMAIL_BODY_REPORT foreign key (EMAIL_BODY_REPORT_ID) references EMAILTEMPLATES_TEMPLATE_REPORT(ID)^
create unique index IDX_EMAILTEMPLATES_EMAIL_TEMPLATE_UNIQ_CODE on EMAILTEMPLATES_EMAIL_TEMPLATE (CODE, DELETE_TS) ^
create index IDX_EMAILTEMPLATES_EMAIL_TEMPLATE_GROUP on EMAILTEMPLATES_EMAIL_TEMPLATE (GROUP_ID)^
-- end EMAILTEMPLATES_EMAIL_TEMPLATE
-- begin EMAILTEMPLATES_TEMPLATE_REPORT
alter table EMAILTEMPLATES_TEMPLATE_REPORT add constraint FK_EMAILTEMPLATES_TEMPLATE_REPORT_REPORT foreign key (REPORT_ID) references REPORT_REPORT(ID)^
alter table EMAILTEMPLATES_TEMPLATE_REPORT add constraint FK_EMAILTEMPLATES_TEMPLATE_REPORT_EMAIL_TEMPLATE foreign key (EMAIL_TEMPLATE_ID) references EMAILTEMPLATES_EMAIL_TEMPLATE(ID)^
create index IDX_EMAILTEMPLATES_TEMPLATE_REPORT_REPORT on EMAILTEMPLATES_TEMPLATE_REPORT (REPORT_ID)^
create index IDX_EMAILTEMPLATES_TEMPLATE_REPORT_EMAIL_TEMPLATE on EMAILTEMPLATES_TEMPLATE_REPORT (EMAIL_TEMPLATE_ID)^
-- end EMAILTEMPLATES_TEMPLATE_REPORT
-- begin EMAILTEMPLATES_EMLTPTE_FDLINK
alter table EMAILTEMPLATES_EMLTPTE_FDLINK add constraint FK_EMLF_EMAIL_TEMPLATE foreign key (EMAIL_TEMPLATE_ID) references EMAILTEMPLATES_EMAIL_TEMPLATE(ID)^
alter table EMAILTEMPLATES_EMLTPTE_FDLINK add constraint FK_EMLF_FILE_DESCRIPTOR foreign key (FILE_DESCRIPTOR_ID) references SYS_FILE(ID)^
-- end EMAILTEMPLATES_EMLTPTE_FDLINK
1 change: 1 addition & 0 deletions modules/core/db/init/mssql/30.create-db.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

93 changes: 93 additions & 0 deletions modules/core/db/init/mysql/10.create-db.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
-- begin EMAILTEMPLATES_PARAMETER_VALUE
create table EMAILTEMPLATES_PARAMETER_VALUE (
ID varchar(32),
VERSION integer not null,
CREATE_TS datetime(3),
CREATED_BY varchar(50),
UPDATE_TS datetime(3),
UPDATED_BY varchar(50),
DELETE_TS datetime(3),
DELETED_BY varchar(50),
--
PARAMETER_TYPE integer not null,
ALIAS varchar(255) not null,
DEFAULT_VALUE varchar(255),
TEMPLATE_PARAMETER_ID varchar(32) not null,
--
primary key (ID)
)^
-- end EMAILTEMPLATES_PARAMETER_VALUE
-- begin EMAILTEMPLATES_TEMPLATE_GROUP
create table EMAILTEMPLATES_TEMPLATE_GROUP (
ID varchar(32),
VERSION integer not null,
CREATE_TS datetime(3),
CREATED_BY varchar(50),
UPDATE_TS datetime(3),
UPDATED_BY varchar(50),
DELETE_TS datetime(3),
DELETED_BY varchar(50),
--
NAME varchar(255) not null,
--
primary key (ID)
)^
-- end EMAILTEMPLATES_TEMPLATE_GROUP
-- begin EMAILTEMPLATES_EMAIL_TEMPLATE
create table EMAILTEMPLATES_EMAIL_TEMPLATE (
ID varchar(32),
VERSION integer not null,
CREATE_TS datetime(3),
CREATED_BY varchar(50),
UPDATE_TS datetime(3),
UPDATED_BY varchar(50),
DELETE_TS datetime(3),
DELETED_BY varchar(50),
DTYPE varchar(100),
--
USE_REPORT_SUBJECT boolean,
NAME varchar(255) not null,
GROUP_ID varchar(32),
TYPE_ varchar(50) not null,
CODE varchar(255) not null,
FROM_ varchar(255),
TO_ longtext,
CC longtext,
BCC longtext,
SUBJECT varchar(255),
--
-- from emailtemplates$ReportEmailTemplate
EMAIL_BODY_REPORT_ID varchar(32),
--
-- from emailtemplates$JsonEmailTemplate
HTML longtext,
REPORT_XML longtext,
--
primary key (ID)
)^
-- end EMAILTEMPLATES_EMAIL_TEMPLATE
-- begin EMAILTEMPLATES_TEMPLATE_REPORT
create table EMAILTEMPLATES_TEMPLATE_REPORT (
ID varchar(32),
VERSION integer not null,
CREATE_TS datetime(3),
CREATED_BY varchar(50),
UPDATE_TS datetime(3),
UPDATED_BY varchar(50),
DELETE_TS datetime(3),
DELETED_BY varchar(50),
--
NAME varchar(255),
REPORT_ID varchar(32) not null,
EMAIL_TEMPLATE_ID varchar(32),
--
primary key (ID)
)^
-- end EMAILTEMPLATES_TEMPLATE_REPORT
-- begin EMAILTEMPLATES_EMLTPTE_FDLINK
create table EMAILTEMPLATES_EMLTPTE_FDLINK (
EMAIL_TEMPLATE_ID varchar(32),
FILE_DESCRIPTOR_ID varchar(32),
primary key (EMAIL_TEMPLATE_ID, FILE_DESCRIPTOR_ID)
)^
-- end EMAILTEMPLATES_EMLTPTE_FDLINK
20 changes: 20 additions & 0 deletions modules/core/db/init/mysql/20.create-db.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
-- begin EMAILTEMPLATES_PARAMETER_VALUE
alter table EMAILTEMPLATES_PARAMETER_VALUE add constraint FK_EMAILTEMPLATES_PARAMETER_VALUE_TEMPLATE_PARAMETER foreign key (TEMPLATE_PARAMETER_ID) references EMAILTEMPLATES_TEMPLATE_REPORT(ID)^
create index IDX_EMAILTEMPLATES_PARAMETER_VALUE_TEMPLATE_PARAMETER on EMAILTEMPLATES_PARAMETER_VALUE (TEMPLATE_PARAMETER_ID)^
-- end EMAILTEMPLATES_PARAMETER_VALUE
-- begin EMAILTEMPLATES_EMAIL_TEMPLATE
alter table EMAILTEMPLATES_EMAIL_TEMPLATE add constraint FK_EMAILTEMPLATES_EMAIL_TEMPLATE_GROUP foreign key (GROUP_ID) references EMAILTEMPLATES_TEMPLATE_GROUP(ID)^
alter table EMAILTEMPLATES_EMAIL_TEMPLATE add constraint FK_EMAILTEMPLATES_EMAIL_TEMPLATE_EMAIL_BODY_REPORT foreign key (EMAIL_BODY_REPORT_ID) references EMAILTEMPLATES_TEMPLATE_REPORT(ID)^
create unique index IDX_EMAILTEMPLATES_EMAIL_TEMPLATE_UNIQ_CODE on EMAILTEMPLATES_EMAIL_TEMPLATE (CODE) ^
create index IDX_EMAILTEMPLATES_EMAIL_TEMPLATE_GROUP on EMAILTEMPLATES_EMAIL_TEMPLATE (GROUP_ID)^
-- end EMAILTEMPLATES_EMAIL_TEMPLATE
-- begin EMAILTEMPLATES_TEMPLATE_REPORT
alter table EMAILTEMPLATES_TEMPLATE_REPORT add constraint FK_EMAILTEMPLATES_TEMPLATE_REPORT_REPORT foreign key (REPORT_ID) references REPORT_REPORT(ID)^
alter table EMAILTEMPLATES_TEMPLATE_REPORT add constraint FK_EMAILTEMPLATES_TEMPLATE_REPORT_EMAIL_TEMPLATE foreign key (EMAIL_TEMPLATE_ID) references EMAILTEMPLATES_EMAIL_TEMPLATE(ID)^
create index IDX_EMAILTEMPLATES_TEMPLATE_REPORT_REPORT on EMAILTEMPLATES_TEMPLATE_REPORT (REPORT_ID)^
create index IDX_EMAILTEMPLATES_TEMPLATE_REPORT_EMAIL_TEMPLATE on EMAILTEMPLATES_TEMPLATE_REPORT (EMAIL_TEMPLATE_ID)^
-- end EMAILTEMPLATES_TEMPLATE_REPORT
-- begin EMAILTEMPLATES_EMLTPTE_FDLINK
alter table EMAILTEMPLATES_EMLTPTE_FDLINK add constraint FK_EMLF_EMAIL_TEMPLATE foreign key (EMAIL_TEMPLATE_ID) references EMAILTEMPLATES_EMAIL_TEMPLATE(ID)^
alter table EMAILTEMPLATES_EMLTPTE_FDLINK add constraint FK_EMLF_FILE_DESCRIPTOR foreign key (FILE_DESCRIPTOR_ID) references SYS_FILE(ID)^
-- end EMAILTEMPLATES_EMLTPTE_FDLINK
1 change: 1 addition & 0 deletions modules/core/db/init/mysql/30.create-db.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
<groupTable id="templateGroupsTable"
width="100%">
<actions>
<action id="create"/>
<action id="edit"/>
<action id="create" openType="DIALOG"/>
<action id="edit" openType="DIALOG"/>
<action id="remove"/>
</actions>
<columns>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
class="com.haulmont.addon.emailtemplates.entity.TemplateGroup"
view="_local"/>
</dsContext>
<dialogMode height="600"
width="800"/>
<dialogMode height="AUTO"
width="AUTO"/>
<layout expand="windowActions"
spacing="true">
<fieldGroup id="fieldGroup"
datasource="templateGroupDs">
<column width="250px">
<column width="400px">
<field property="name"/>
</column>
</fieldGroup>
Expand Down

0 comments on commit 6b1f712

Please sign in to comment.