1 -- +--------------------------------------------------------------------+
2 -- | CiviCRM version 4.5 |
3 -- +--------------------------------------------------------------------+
4 -- | Copyright CiviCRM LLC (c) 2004-2014 |
5 -- +--------------------------------------------------------------------+
6 -- | This file is a part of CiviCRM. |
8 -- | CiviCRM is free software; you can copy, modify, and distribute it |
9 -- | under the terms of the GNU Affero General Public License |
10 -- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
12 -- | CiviCRM is distributed in the hope that it will be useful, but |
13 -- | WITHOUT ANY WARRANTY; without even the implied warranty of |
14 -- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
15 -- | See the GNU Affero General Public License for more details. |
17 -- | You should have received a copy of the GNU Affero General Public |
18 -- | License and the CiviCRM Licensing Exception along |
19 -- | with this program; if not, contact CiviCRM LLC |
20 -- | at info[AT]civicrm[DOT]org. If you have questions about the |
21 -- | GNU Affero General Public License or the licensing of CiviCRM, |
22 -- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
23 -- +--------------------------------------------------------------------+
25 -- Generated from {$smarty.template}
30 {include file="drop.tpl"}
32 -- /*******************************************************
34 -- * Create new tables
36 -- *******************************************************/
38 {foreach from=$tables item=table}
39 -- /*******************************************************
47 -- *******************************************************/
48 CREATE TABLE `{$table.name}` (
49 {assign var='first' value=true}
51 {foreach from=$table.fields item=field}
53 {assign var='first' value=false}
55 `{$field.name}` {$field.sqlType}{if $field.collate} COLLATE {$field.collate}{/if} {if $field.required}{if $field.required == "false"}NULL{else}NOT NULL{/if}{/if} {if $field.autoincrement}AUTO_INCREMENT{/if} {if $field.default|count_characters}DEFAULT {$field.default}{/if} {if $field.comment}COMMENT '{$field.comment}'{/if}
56 {/foreach} {* table.fields *}
58 {if $table.primaryKey}
60 {assign var='first' value=false}
62 PRIMARY KEY ( `{$table.primaryKey.name}` )
63 {/if} {* table.primaryKey *}
66 {foreach from=$table.index item=index}
68 {assign var='first' value=false}
69 {if $index.unique} UNIQUE{/if} INDEX `{$index.name}`(
70 {assign var='firstIndexField' value=true}
71 {foreach from=$index.field item=fieldName}
72 {if $firstIndexField}{assign var='firstIndexField' value=false}{else}, {/if}{$fieldName}
75 {/foreach} {* table.index *}
76 {/if} {* table.index *}
78 {if $table.foreignKey}
79 {foreach from=$table.foreignKey item=foreign}
81 {assign var='first' value=false}
82 {if $mysql eq 'simple'} INDEX FKEY_{$foreign.name} ( `{$foreign.name}` ) , {/if}
83 CONSTRAINT {$foreign.uniqName} FOREIGN KEY (`{$foreign.name}`) REFERENCES `{$foreign.table}`(`{$foreign.key}`) {if $foreign.onDelete}ON DELETE {$foreign.onDelete}{/if}
84 {/foreach} {* table.foreignKey *}
85 {/if} {* table.foreignKey *}
87 {* ) {if $mysql eq 'modern' }{$table.attributes}{/if}; *}
88 ) {if $mysql eq 'modern' } {$table.attributes_modern} {else} {$table.attributes_simple} {/if} ;
90 {/foreach} {* tables *}