commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-old / civicrm / xml / templates / schema.tpl
1 -- +--------------------------------------------------------------------+
2 -- | CiviCRM version 4.6 |
3 -- +--------------------------------------------------------------------+
4 -- | Copyright CiviCRM LLC (c) 2004-2015 |
5 -- +--------------------------------------------------------------------+
6 -- | This file is a part of CiviCRM. |
7 -- | |
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. |
11 -- | |
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. |
16 -- | |
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 -- +--------------------------------------------------------------------+
24 --
25 -- Generated from {$smarty.template}
26 -- {$generated}
27 --
28 {$database.comments}
29
30 {include file="drop.tpl"}
31
32 -- /*******************************************************
33 -- *
34 -- * Create new tables
35 -- *
36 -- *******************************************************/
37
38 {foreach from=$tables item=table}
39 -- /*******************************************************
40 -- *
41 -- * {$table.name}
42 {if $table.comment}
43 -- *
44 -- * {$table.comment}
45 {/if}
46 -- *
47 -- *******************************************************/
48 CREATE TABLE `{$table.name}` (
49 {assign var='first' value=true}
50
51 {foreach from=$table.fields item=field}
52 {if ! $first},{/if}
53 {assign var='first' value=false}
54
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 '{ts escape=sql}{$field.comment}{/ts}'{/if}
56 {/foreach} {* table.fields *}
57
58 {if $table.primaryKey}
59 {if ! $first},{/if}
60 {assign var='first' value=false}
61
62 PRIMARY KEY ( `{$table.primaryKey.name}` )
63 {/if} {* table.primaryKey *}
64
65 {if $table.index}
66 {foreach from=$table.index item=index}
67 {if ! $first},{/if}
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}
73 {/foreach}
74 )
75 {/foreach} {* table.index *}
76 {/if} {* table.index *}
77
78 {if $table.foreignKey}
79 {foreach from=$table.foreignKey item=foreign}
80 {if ! $first},{/if}
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 *}
86
87 {* ) {if $mysql eq 'modern' }{$table.attributes}{/if}; *}
88 ) {if $mysql eq 'modern' } {$table.attributes_modern} {else} {$table.attributes_simple} {/if} ;
89
90 {/foreach} {* tables *}