src-db/database/build-create.xml
author RM packaging bot <staff.rm@openbravo.com>
Fri, 18 Sep 2015 16:37:57 +0000
changeset 27602 9f3453d4f213
parent 27153 08f447bbcf10
child 32018 3af52a62c6c2
permissions -rw-r--r--
CI: update AD_MODULE to version 27601
asier@1929
     1
<?xml version="1.0" encoding="UTF-8" ?>
asier@1929
     2
<!--
asier@1929
     3
 *************************************************************************
asier@1929
     4
 * The contents of this file are subject to the Openbravo  Public  License
priya@9072
     5
 * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
asier@1929
     6
 * Version 1.1  with a permitted attribution clause; you may not  use this
asier@1929
     7
 * file except in compliance with the License. You  may  obtain  a copy of
asier@1929
     8
 * the License at http://www.openbravo.com/legal/license.html 
asier@1929
     9
 * Software distributed under the License  is  distributed  on  an "AS IS"
asier@1929
    10
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
asier@1929
    11
 * License for the specific  language  governing  rights  and  limitations
asier@1929
    12
 * under the License. 
asier@1929
    13
 * The Original Code is Openbravo ERP. 
ggi@6701
    14
 * The Initial Developer of the Original Code is Openbravo SLU 
stefan@27153
    15
 * All portions are Copyright (C) 2001-2015 Openbravo SLU 
asier@1929
    16
 * All Rights Reserved. 
asier@1929
    17
 * Contributor(s):  ______________________________________.
asier@1929
    18
 ************************************************************************
asier@1929
    19
-->
asier@1929
    20
<!--
asier@1929
    21
List of targets:
asier@1929
    22
asier@1929
    23
create.database: creates the database from scratch.
asier@1929
    24
-->
asier@1929
    25
<project name="openbravo" default="create.database" basedir=".">
asier@1929
    26
  <property environment="env" />
asier@1929
    27
  <condition property="bbdd.owner.url" value="${bbdd.url}/${bbdd.sid}" else="${bbdd.url}">
asier@1929
    28
    <and>
martin@2869
    29
      <equals arg1="${bbdd.rdbms}" arg2="POSTGRE" />
asier@1929
    30
    </and>
asier@1929
    31
  </condition>
asier@1929
    32
asier@1929
    33
asier@1929
    34
asier@1929
    35
  <path id="runtime-classpath-create">
asier@1929
    36
    <fileset dir="./lib">
asier@1929
    37
      <include name="**/*.jar" />
asier@1929
    38
    </fileset>
asier@1929
    39
    <pathelement path="${build}" />
asier@1929
    40
    <fileset dir="${base.lib}">
martin@2869
    41
      <include name="**/*.jar" />
asier@1929
    42
    </fileset>
asier@1929
    43
  </path>
martin@2869
    44
martin@2869
    45
  <taskdef name="createdatabase" classname="org.openbravo.ddlutils.task.CreateDatabase">
asier@1929
    46
    <classpath refid="runtime-classpath-create" />
asier@1929
    47
  </taskdef>
martin@2869
    48
asier@1929
    49
  <target name="create.database">
martin@2869
    50
    <antcall target="clean.database.${bbdd.rdbms}" />
stefan@27153
    51
    <antcall target="${bbdd.rdbms}.structure" />
antonio@4270
    52
    <antcall target="create.database.all" />
asier@1929
    53
    <antcall target="database.postcreate.${bbdd.rdbms}" />
martin@2869
    54
    <antcall target="update.dbupdate.timestamp" />
asier@1929
    55
  </target>
asier@1929
    56
asier@1929
    57
asier@1929
    58
antonio@2151
    59
asier@1929
    60
  <target name="clean.database.ORACLE">
martin@2869
    61
    <sql driver="${bbdd.driver}" url="${bbdd.url}" userid="${bbdd.systemUser}" password="${bbdd.systemPassword}" onerror="continue">
asier@1929
    62
      <classpath>
asier@1929
    63
        <fileset dir="${base.lib}">
asier@1929
    64
          <include name="**/*.jar">
asier@1929
    65
          </include>
asier@1929
    66
        </fileset>
asier@1929
    67
      </classpath>
asier@1929
    68
      <transaction>
asier@1929
    69
        DROP USER ${bbdd.user} CASCADE;
asier@1929
    70
      </transaction>
asier@1929
    71
    </sql>
asier@1929
    72
  </target>
asier@1929
    73
asier@1929
    74
  <target name="clean.database.POSTGRE">
rafael@26332
    75
    <sql driver="${bbdd.driver}" url="${bbdd.url}/postgres" userid="${bbdd.systemUser}" password="${bbdd.systemPassword}" autocommit="true">
asier@1929
    76
      <classpath>
asier@1929
    77
        <fileset dir="${base.lib}">
asier@1929
    78
          <include name="**/*.jar">
asier@1929
    79
          </include>
asier@1929
    80
        </fileset>
asier@1929
    81
      </classpath>
asier@1929
    82
      <transaction>
rafael@26332
    83
        DROP DATABASE IF EXISTS ${bbdd.sid};
asier@1929
    84
      </transaction>
asier@1929
    85
    </sql>
antonio@15373
    86
    <sql driver="${bbdd.driver}" url="${bbdd.url}/postgres" userid="${bbdd.systemUser}" password="${bbdd.systemPassword}" onerror="continue" autocommit="true">
asier@1929
    87
      <classpath>
asier@1929
    88
        <fileset dir="${base.lib}">
asier@1929
    89
          <include name="**/*.jar">
asier@1929
    90
          </include>
asier@1929
    91
        </fileset>
asier@1929
    92
      </classpath>
asier@1929
    93
      <transaction>
asier@1929
    94
        DROP ROLE ${bbdd.user};
asier@1929
    95
      </transaction>
asier@1929
    96
    </sql>
asier@1929
    97
  </target>
asier@1929
    98
asier@1929
    99
  <target name="ORACLE.structure">
martin@2869
   100
    <sql driver="${bbdd.driver}" url="${bbdd.url}" userid="${bbdd.systemUser}" password="${bbdd.systemPassword}" delimiter="/">
asier@1929
   101
      <classpath>
asier@1929
   102
        <fileset dir="${base.lib}">
asier@1929
   103
          <include name="**/*.jar">
asier@1929
   104
          </include>
asier@1929
   105
        </fileset>
asier@1929
   106
      </classpath>
asier@1929
   107
      <transaction>
asier@1929
   108
        --CHEKING IF USER EXISTS
asier@1929
   109
        DECLARE
asier@1929
   110
          v_count NUMBER;
asier@1929
   111
        BEGIN
asier@1929
   112
          SELECT COUNT(*) INTO v_count FROM DBA_USERS WHERE USERNAME = '${bbdd.user}';
asier@1929
   113
          IF (v_count > 0) THEN
asier@1929
   114
            RAISE_APPLICATION_ERROR(-20100, '${bbdd.user} ALREADY EXISTS. SELECT ANOTHER USER OR DROP IT FIRST');
asier@1929
   115
          END IF;
asier@1929
   116
        END;
asier@1929
   117
        /
asier@1929
   118
      </transaction>
asier@1929
   119
asier@1929
   120
    </sql>
martin@2869
   121
    <sql driver="${bbdd.driver}" url="${bbdd.url}" userid="${bbdd.systemUser}" password="${bbdd.systemPassword}" onerror="continue">
asier@1929
   122
      <classpath>
asier@1929
   123
        <fileset dir="${base.lib}">
asier@1929
   124
          <include name="**/*.jar">
asier@1929
   125
          </include>
asier@1929
   126
        </fileset>
asier@1929
   127
      </classpath>
asier@1929
   128
      <transaction>
asier@1929
   129
        --UPDATING OPEN CURSORS NUMBER
asier@1929
   130
        ALTER SYSTEM SET OPEN_CURSORS = 10000 SCOPE=BOTH;
asier@1929
   131
      </transaction>
asier@1929
   132
    </sql>
antonio@5309
   133
    <sql driver="${bbdd.driver}" url="${bbdd.url}" userid="${bbdd.systemUser}" password="${bbdd.systemPassword}">
asier@1929
   134
      <classpath>
asier@1929
   135
        <fileset dir="${base.lib}">
asier@1929
   136
          <include name="**/*.jar">
asier@1929
   137
          </include>
asier@1929
   138
        </fileset>
asier@1929
   139
      </classpath>
asier@1929
   140
      <transaction>
asier@1929
   141
        --CREATING USER
asier@1929
   142
        CREATE USER ${bbdd.user} IDENTIFIED BY ${bbdd.password}
asier@1929
   143
        DEFAULT TABLESPACE USERS
asier@1929
   144
        TEMPORARY TABLESPACE TEMP;
asier@1929
   145
asier@1929
   146
        --GRANTING USER
asier@1929
   147
      	grant create session     to ${bbdd.user};
asier@1929
   148
      	grant alter  session     to ${bbdd.user};
asier@1929
   149
      	grant create table       to ${bbdd.user};
asier@1929
   150
      	grant create procedure   to ${bbdd.user};
asier@1929
   151
      	grant create trigger     to ${bbdd.user};
asier@1929
   152
      	grant create view        to ${bbdd.user};
antonio@3962
   153
        grant create sequence    to ${bbdd.user};
asier@1929
   154
      	alter user ${bbdd.user} quota unlimited on users;
asier@1929
   155
      </transaction>
asier@1929
   156
    </sql>
asier@1929
   157
  </target>
asier@1929
   158
asier@1929
   159
  <target name="POSTGRE.structure">
antonio@15373
   160
    <sql driver="${bbdd.driver}" url="${bbdd.url}/postgres" userid="${bbdd.systemUser}" password="${bbdd.systemPassword}" onerror="continue" autocommit="true">
asier@1929
   161
      <classpath>
asier@1929
   162
        <fileset dir="${base.lib}">
asier@1929
   163
          <include name="**/*.jar">
asier@1929
   164
          </include>
asier@1929
   165
        </fileset>
asier@1929
   166
      </classpath>
asier@1929
   167
      <transaction>
asier@1929
   168
        --CREATING USER
asier@1929
   169
        CREATE ROLE ${bbdd.user} LOGIN PASSWORD '${bbdd.password}'
asier@1929
   170
               SUPERUSER CREATEDB CREATEROLE
asier@1929
   171
               VALID UNTIL 'infinity';
asier@1929
   172
      </transaction>
asier@1929
   173
    </sql>
antonio@15373
   174
    <sql driver="${bbdd.driver}" url="${bbdd.url}/postgres" userid="${bbdd.systemUser}" password="${bbdd.systemPassword}" autocommit="true">
asier@1929
   175
      <classpath>
asier@1929
   176
        <fileset dir="${base.lib}">
asier@1929
   177
          <include name="**/*.jar">
asier@1929
   178
          </include>
asier@1929
   179
        </fileset>
asier@1929
   180
      </classpath>
asier@1929
   181
      <transaction>
asier@1929
   182
        CREATE DATABASE ${bbdd.sid}
asier@1929
   183
                  WITH ENCODING='UTF8'
antonio@3475
   184
                  OWNER=${bbdd.user}
antonio@3475
   185
                  TEMPLATE=template0;
asier@1929
   186
      </transaction>
asier@1929
   187
    </sql>
asier@1929
   188
  </target>
asier@1929
   189
antonio@4270
   190
  <target name="create.database.all">
antonio@4270
   191
    <createdatabase driver="${bbdd.driver}" url="${bbdd.owner.url}" user="${bbdd.user}" password="${bbdd.password}" model="model" object="${bbdd.object}" dropfirst="false" failonerror="false" verbosity="${bbdd.verbosity}" basedir="${base.db}/../.." modulesDir="${base.modules}/" dirFilter="*/src-db/database/model" filter="com.openbravo.db.OpenbravoMetadataFilter" input="src-db/database/sourcedata,modules/*/src-db/database/sourcedata">
martin@2869
   192
    </createdatabase>
martin@2869
   193
    <antcall target="database.poststructure.${bbdd.rdbms}" />
martin@2869
   194
  </target>
asier@1929
   195
asier@1929
   196
asier@1929
   197
  <target name="database.postcreate.ORACLE">
antonio@3145
   198
    <sql driver="${bbdd.driver}" url="${bbdd.owner.url}" userid="${bbdd.user}" password="${bbdd.password}" onerror="abort" autocommit="true">
martin@2869
   199
      <classpath>
martin@2869
   200
        <fileset dir="${base.lib}">
martin@2869
   201
          <include name="**/*.jar">
martin@2869
   202
          </include>
martin@2869
   203
        </fileset>
martin@2869
   204
      </classpath>
martin@2869
   205
      <transaction>
asier@1929
   206
          DELETE FROM AD_SYSTEM;
asier@1929
   207
          INSERT INTO AD_SYSTEM (AD_SYSTEM_ID, AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY, UPDATED, UPDATEDBY, NAME, TAD_RECORDRANGE, TAD_RECORDRANGE_INFO,  TAD_TRANSACTIONALRANGE, TAD_THEME)
asier@10182
   208
          VALUES ('0', '0', '0', 'Y', NOW(), '0', NOW(), '0', '?', 20, 100,  1, 
asier@10182
   209
                  (SELECT Value 
asier@10182
   210
				     FROM (SELECT Value 
asier@10182
   211
					         FROM AD_Ref_List 
asier@10182
   212
                            WHERE AD_Ref_List_ID IN ('800247', '27F0D1235450423C814D3A0DCABA7D10')
asier@10182
   213
                            ORDER BY (CASE WHEN Name ='Default' THEN 2 ELSE 1 END))
asier@10182
   214
                    WHERE RowNum = 1));
asier@1929
   215
          DELETE FROM AD_SYSTEM_INFO;
stefan@20698
   216
          INSERT INTO AD_SYSTEM_INFO(AD_SYSTEM_INFO_ID, AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY, UPDATED, UPDATEDBY, ANT_VERSION, OB_INSTALLMODE, CODE_REVISION, MATURITY_UPDATE, MATURITY_SEARCH,
stefan@20698
   217
                your_company_login_image, your_it_service_login_image, your_company_menu_image, your_company_big_image, your_company_document_image, support_contact)
stefan@20698
   218
          VALUES('0', '0', '0', 'Y', NOW(), '0', NOW(), '0', '${ant.version}', 'From Sources', SUBSTR('${code.revision}',1,60), '200', '200',
stefan@20698
   219
                '37B37B6A8876462780DB969E5C4D81FD', '6C216D1786B34105ACCBA4DD8612A0CE', '5F3C04DF603F409A875C294910BD3491', 'B48852CB1AE641288F037EB59F968328', 'AA90B7900AD04E87A890BA2E2604A6D9', 'www.your-it-service.com');
asier@1929
   220
          DELETE FROM AD_REGISTRATION_INFO;
asier@1929
   221
          INSERT INTO AD_REGISTRATION_INFO(AD_REGISTRATION_INFO_ID, AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY, UPDATED, UPDATEDBY)
asier@1929
   222
          VALUES('0', '0', '0', 'Y', NOW(), '0', NOW(), '0');
asier@1929
   223
          CALL AD_UPDATE_ACCESS();
augusto@25163
   224
      	  ${bbdd.sessionConfig};
antonio@5133
   225
          SELECT AD_DB_MODIFIED('Y') FROM DUAL;
antonio@2025
   226
          UPDATE AD_MODULE SET ISINDEVELOPMENT='N', ISDEFAULT='N', SEQNO=NULL, STATUS='P', UPDATE_AVAILABLE=NULL, ISREGISTERED='N' WHERE STATUS IS NULL OR STATUS='I';
asier@3996
   227
          CALL AD_LANGUAGE_CREATE(NULL);
asier@1929
   228
        </transaction>
asier@1929
   229
    </sql>
antonio@2911
   230
    <sql driver="${bbdd.driver}" url="${bbdd.owner.url}" userid="${bbdd.user}" password="${bbdd.password}" onerror="continue" autocommit="true" delimitertype="row">
antonio@2911
   231
      <classpath>
antonio@2911
   232
        <fileset dir="${base.lib}">
antonio@2911
   233
          <include name="**/*.jar">
antonio@2911
   234
          </include>
antonio@2911
   235
        </fileset>
antonio@2911
   236
      </classpath>
antonio@2911
   237
      <transaction>
antonio@2911
   238
          BEGIN
antonio@2911
   239
            DBMS_STATS.gather_schema_stats (ownname => UPPER('${bbdd.user}'), estimate_percent => DBMS_STATS.AUTO_SAMPLE_SIZE, cascade =>TRUE);
antonio@2911
   240
          END;
antonio@2911
   241
        </transaction>
antonio@2911
   242
    </sql>
asier@1929
   243
  </target>
asier@1929
   244
asier@1929
   245
  <target name="database.postcreate.POSTGRE">
antonio@3145
   246
    <sql driver="${bbdd.driver}" url="${bbdd.owner.url}" userid="${bbdd.user}" password="${bbdd.password}" onerror="abort" autocommit="true">
martin@2869
   247
      <classpath>
martin@2869
   248
        <fileset dir="${base.lib}">
martin@2869
   249
          <include name="**/*.jar">
martin@2869
   250
          </include>
martin@2869
   251
        </fileset>
martin@2869
   252
      </classpath>
martin@2869
   253
      <transaction>
asier@1929
   254
          DELETE FROM AD_SYSTEM;
asier@1929
   255
          INSERT INTO AD_SYSTEM (AD_SYSTEM_ID, AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY, UPDATED, UPDATEDBY, NAME, TAD_RECORDRANGE, TAD_RECORDRANGE_INFO, TAD_TRANSACTIONALRANGE, TAD_THEME)
asier@10182
   256
          VALUES ('0', '0', '0', 'Y', NOW(), '0', NOW(), '0', '?', 20, 100, 1, 
asier@10182
   257
		          (SELECT Value FROM AD_Ref_List 
asier@10182
   258
                    WHERE AD_Ref_List_ID in ('800247', '27F0D1235450423C814D3A0DCABA7D10')
asier@10182
   259
                    ORDER BY (CASE WHEN Name ='Default' THEN 2 ELSE 1 END)
asier@10182
   260
                    LIMIT 1));
asier@1929
   261
          DELETE FROM AD_SYSTEM_INFO;
stefan@20698
   262
          INSERT INTO AD_SYSTEM_INFO(AD_SYSTEM_INFO_ID, AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY, UPDATED, UPDATEDBY, ANT_VERSION, OB_INSTALLMODE, CODE_REVISION, MATURITY_UPDATE, MATURITY_SEARCH,
stefan@20698
   263
                your_company_login_image, your_it_service_login_image, your_company_menu_image, your_company_big_image, your_company_document_image, support_contact)
stefan@20698
   264
          VALUES('0', '0', '0', 'Y', NOW(), '0', NOW(), '0', '${ant.version}', 'From Sources', SUBSTR('${code.revision}',1,60), '200', '200',
stefan@20698
   265
                '37B37B6A8876462780DB969E5C4D81FD', '6C216D1786B34105ACCBA4DD8612A0CE', '5F3C04DF603F409A875C294910BD3491', 'B48852CB1AE641288F037EB59F968328', 'AA90B7900AD04E87A890BA2E2604A6D9', 'www.your-it-service.com');
asier@1929
   266
          DELETE FROM AD_REGISTRATION_INFO;
asier@1929
   267
          INSERT INTO AD_REGISTRATION_INFO(AD_REGISTRATION_INFO_ID, AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY, UPDATED, UPDATEDBY)
asier@1929
   268
          VALUES('0', '0', '0', 'Y', NOW(), '0', NOW(), '0');
asier@1929
   269
          SELECT AD_UPDATE_ACCESS();
augusto@25163
   270
          ${bbdd.sessionConfig};
antonio@5128
   271
          SELECT AD_DB_MODIFIED('Y');
antonio@2025
   272
          UPDATE AD_MODULE SET ISINDEVELOPMENT='N', ISDEFAULT='N', SEQNO=NULL, STATUS='P', UPDATE_AVAILABLE=NULL, ISREGISTERED='N' WHERE STATUS IS NULL OR STATUS='I';
asier@3996
   273
          SELECT AD_LANGUAGE_CREATE(NULL);
antonio@2911
   274
          ANALYZE;
asier@1929
   275
        </transaction>
asier@1929
   276
    </sql>
asier@1929
   277
  </target>
asier@1929
   278
asier@1929
   279
  <target name="database.poststructure.ORACLE">
martin@2869
   280
    <sql driver="${bbdd.driver}" url="${bbdd.owner.url}" userid="${bbdd.user}" password="${bbdd.password}" onerror="continue" autocommit="true">
martin@2869
   281
      <classpath>
martin@2869
   282
        <fileset dir="${base.lib}">
martin@2869
   283
          <include name="**/*.jar">
martin@2869
   284
          </include>
martin@2869
   285
        </fileset>
martin@2869
   286
      </classpath>
martin@2869
   287
      <transaction>
asier@1929
   288
            PURGE RECYCLEBIN;
asier@1929
   289
        </transaction>
asier@1929
   290
    </sql>
asier@1929
   291
  </target>
asier@1929
   292
  <target name="database.poststructure.POSTGRE">
asier@1929
   293
  </target>
asier@1929
   294
antonio@2824
   295
  <target name="update.dbupdate.timestamp">
martin@2869
   296
    <sql driver="${bbdd.driver}" url="${bbdd.owner.url}" userid="${bbdd.user}" password="${bbdd.password}" onerror="continue" autocommit="true">
martin@2869
   297
      <classpath>
martin@2869
   298
        <fileset dir="${base.lib}">
martin@2869
   299
          <include name="**/*.jar">
martin@2869
   300
          </include>
martin@2869
   301
        </fileset>
martin@2869
   302
      </classpath>
martin@2869
   303
      <transaction>
antonio@2824
   304
          UPDATE AD_SYSTEM_INFO SET LAST_DBUPDATE=NOW()
antonio@2824
   305
        </transaction>
martin@2869
   306
    </sql>
martin@2869
   307
  </target>
asier@1929
   308
</project>