~ubuntu-branches/ubuntu/oneiric/bugzilla/oneiric

« back to all changes in this revision

Viewing changes to docs/html/api/Bugzilla/DB/Schema.html

  • Committer: Bazaar Package Importer
  • Author(s): Raphael Bossek
  • Date: 2008-06-27 22:34:34 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20080627223434-0ib57vstn43bb4a3
Tags: 3.0.4.1-1
* Update of French, Russian and German translations. (closes: #488251)
* Added Bulgarian and Belarusian translations.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2
 
<html>
3
 
  <head>
4
 
    <title>
5
 
Bugzilla::DB::Schema</title>
6
 
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
7
 
  <link rel="stylesheet" title="style" type="text/css" href="../../style.css" media="all" >
8
 
 
9
 
</head>
10
 
  <body id="pod">
11
 
<p class="backlinktop"><b><a name="___top" href="../../index.html" accesskey="1" title="All Documents">&lt;&lt;</a></b></p>
12
 
<h1>Bugzilla::DB::Schema</h1>
13
 
<div class='indexgroup'>
14
 
<ul   class='indexList indexList1'>
15
 
  <li class='indexItem indexItem1'><a href='#NAME'>NAME</a>
16
 
  <li class='indexItem indexItem1'><a href='#SYNOPSIS'>SYNOPSIS</a>
17
 
  <li class='indexItem indexItem1'><a href='#DESCRIPTION'>DESCRIPTION</a>
18
 
  <li class='indexItem indexItem1'><a href='#NEW_TO_SCHEMA.PM%3F'>NEW TO SCHEMA.PM?</a>
19
 
  <li class='indexItem indexItem1'><a href='#CONSTANTS'>CONSTANTS</a>
20
 
  <li class='indexItem indexItem1'><a href='#METHODS'>METHODS</a>
21
 
  <li class='indexItem indexItem1'><a href='#SERIALIZATION%2FDESERIALIZATION'>SERIALIZATION/DESERIALIZATION</a>
22
 
  <li class='indexItem indexItem1'><a href='#CLASS_METHODS'>CLASS METHODS</a>
23
 
  <li class='indexItem indexItem1'><a href='#ABSTRACT_DATA_TYPES'>ABSTRACT DATA TYPES</a>
24
 
  <li class='indexItem indexItem1'><a href='#SEE_ALSO'>SEE ALSO</a>
25
 
</ul>
26
 
</div>
27
 
 
28
 
<h1><a class='u' href='#___top' title='click to go to top of document'
29
 
name="NAME"
30
 
>NAME</a></h1>
31
 
 
32
 
<p>Bugzilla::DB::Schema - Abstract database schema for Bugzilla</p>
33
 
 
34
 
<h1><a class='u' href='#___top' title='click to go to top of document'
35
 
name="SYNOPSIS"
36
 
>SYNOPSIS</a></h1>
37
 
 
38
 
<pre  class="code">  # Obtain MySQL database schema.
39
 
  # Do not do this. Use Bugzilla::DB instead.
40
 
  use Bugzilla::DB::Schema;
41
 
  my $mysql_schema = new Bugzilla::DB::Schema(&#39;Mysql&#39;);
42
 
 
43
 
  # Recommended way to obtain database schema.
44
 
  use Bugzilla::DB;
45
 
  my $dbh = Bugzilla-&#62;dbh;
46
 
  my $schema = $dbh-&#62;_bz_schema();
47
 
 
48
 
  # Get the list of tables in the Bugzilla database.
49
 
  my @tables = $schema-&#62;get_table_list();
50
 
 
51
 
  # Get the SQL statements need to create the bugs table.
52
 
  my @statements = $schema-&#62;get_table_ddl(&#39;bugs&#39;);
53
 
 
54
 
  # Get the database-specific SQL data type used to implement
55
 
  # the abstract data type INT1.
56
 
  my $db_specific_type = $schema-&#62;sql_type(&#39;INT1&#39;);</pre>
57
 
 
58
 
<h1><a class='u' href='#___top' title='click to go to top of document'
59
 
name="DESCRIPTION"
60
 
>DESCRIPTION</a></h1>
61
 
 
62
 
<p>This module implements an object-oriented, abstract database schema. It should be considered package-private to the Bugzilla::DB module. That means that CGI scripts should never call any function in this module directly, but should instead rely on methods provided by Bugzilla::DB.</p>
63
 
 
64
 
<h1><a class='u' href='#___top' title='click to go to top of document'
65
 
name="NEW_TO_SCHEMA.PM?"
66
 
>NEW TO SCHEMA.PM?</a></h1>
67
 
 
68
 
<p>If this is your first time looking at Schema.pm, especially if you are making changes to the database, please take a look at <a href="http://www.bugzilla.org/docs/developer.html#sql-schema" class="podlinkurl"
69
 
>http://www.bugzilla.org/docs/developer.html#sql-schema</a> to learn more about how this integrates into the rest of Bugzilla.</p>
70
 
 
71
 
<h1><a class='u' href='#___top' title='click to go to top of document'
72
 
name="CONSTANTS"
73
 
>CONSTANTS</a></h1>
74
 
 
75
 
<dl>
76
 
<dt><a name="SCHEMA_VERSION"
77
 
><code  class="code">SCHEMA_VERSION</code></a></dt>
78
 
 
79
 
<dd>
80
 
<p>The &#39;version&#39; of the internal schema structure. This version number is incremented every time the the fundamental structure of Schema internals changes.</p>
81
 
 
82
 
<p>This is NOT changed every time a table or a column is added. This number is incremented only if the internal structures of this Schema would be incompatible with the internal structures of a previous Schema version.</p>
83
 
 
84
 
<p>In general, unless you are messing around with serialization and deserialization of the schema, you don&#39;t need to worry about this constant.</p>
85
 
 
86
 
<dt><a name="ABSTRACT_SCHEMA"
87
 
><code  class="code">ABSTRACT_SCHEMA</code></a></dt>
88
 
 
89
 
<dd>
90
 
<p>The abstract database schema structure consists of a hash reference in which each key is the name of a table in the Bugzilla database.</p>
91
 
 
92
 
<p>The value for each key is a hash reference containing the keys <code  class="code">FIELDS</code> and <code  class="code">INDEXES</code> which in turn point to array references containing information on the table&#39;s fields and indexes.</p>
93
 
 
94
 
<p>A field hash reference should must contain the key <code  class="code">TYPE</code>. Optional field keys include <code  class="code">PRIMARYKEY</code>, <code  class="code">NOTNULL</code>, and <code  class="code">DEFAULT</code>.</p>
95
 
 
96
 
<p>The <code  class="code">INDEXES</code> array reference contains index names and information regarding the index. If the index name points to an array reference, then the index is a regular index and the array contains the indexed columns. If the index name points to a hash reference, then the hash must contain the key <code  class="code">FIELDS</code>. It may also contain the key <code  class="code">TYPE</code>, which can be used to specify the type of index such as UNIQUE or FULLTEXT.</p>
97
 
</dd>
98
 
</dl>
99
 
 
100
 
<h1><a class='u' href='#___top' title='click to go to top of document'
101
 
name="METHODS"
102
 
>METHODS</a></h1>
103
 
 
104
 
<p>Note: Methods which can be implemented generically for all DBs are implemented in this module. If needed, they can be overridden with DB-specific code in a subclass. Methods which are prefixed with <code  class="code">_</code> are considered protected. Subclasses may override these methods, but other modules should not invoke these methods directly.</p>
105
 
 
106
 
<dl>
107
 
<dt><a name="new"
108
 
><code  class="code">new</code></a></dt>
109
 
 
110
 
<dd>
111
 
<pre  class="code"> Description: Public constructor method used to instantiate objects of this
112
 
              class. However, it also can be used as a factory method to
113
 
              instantiate database-specific subclasses when an optional
114
 
              driver argument is supplied.
115
 
 Parameters:  $driver (optional) - Used to specify the type of database.
116
 
              This routine C&#60;die&#62;s if no subclass is found for the specified
117
 
              driver.
118
 
              $schema (optional) - A reference to a hash. Callers external
119
 
                  to this package should never use this parameter.
120
 
 Returns:     new instance of the Schema class or a database-specific subclass</pre>
121
 
 
122
 
<dt><a name="_initialize"
123
 
><code  class="code">_initialize</code></a></dt>
124
 
 
125
 
<dd>
126
 
<pre  class="code"> Description: Protected method that initializes an object after
127
 
              instantiation with the abstract schema. All subclasses should
128
 
              override this method. The typical subclass implementation
129
 
              should first call the C&#60;_initialize&#62; method of the superclass,
130
 
              then do any database-specific initialization (especially
131
 
              define the database-specific implementation of the all
132
 
              abstract data types), and then call the C&#60;_adjust_schema&#62;
133
 
              method.
134
 
 Parameters:  $abstract_schema (optional) - A reference to a hash. If 
135
 
                  provided, this hash will be used as the internal
136
 
                  representation of the abstract schema instead of our
137
 
                  default abstract schema. This is intended for internal 
138
 
                  use only by deserialize_abstract.
139
 
 Returns:     the instance of the Schema class</pre>
140
 
 
141
 
<dt><a name="_adjust_schema"
142
 
><code  class="code">_adjust_schema</code></a></dt>
143
 
 
144
 
<dd>
145
 
<pre  class="code"> Description: Protected method that alters the abstract schema at
146
 
              instantiation-time to be database-specific. It is a generic
147
 
              enough routine that it can be defined here in the base class.
148
 
              It takes the abstract schema and replaces the abstract data
149
 
              types with database-specific data types.
150
 
 Parameters:  none
151
 
 Returns:     the instance of the Schema class</pre>
152
 
 
153
 
<dt><a name="get_type_ddl"
154
 
><code  class="code">get_type_ddl</code></a></dt>
155
 
 
156
 
<dd>
157
 
<pre  class="code"> Description: Public method to convert abstract (database-generic) field
158
 
              specifiers to database-specific data types suitable for use
159
 
              in a C&#60;CREATE TABLE&#62; or C&#60;ALTER TABLE&#62; SQL statment. If no
160
 
              database-specific field type has been defined for the given
161
 
              field type, then it will just return the same field type.
162
 
 Parameters:  a hash or a reference to a hash of a field containing the
163
 
              following keys: C&#60;TYPE&#62; (required), C&#60;NOTNULL&#62; (optional),
164
 
              C&#60;DEFAULT&#62; (optional), C&#60;PRIMARYKEY&#62; (optional), C&#60;REFERENCES&#62;
165
 
              (optional)
166
 
 Returns:     a DDL string suitable for describing a field in a
167
 
              C&#60;CREATE TABLE&#62; or C&#60;ALTER TABLE&#62; SQL statement</pre>
168
 
 
169
 
<dt><a name="convert_type"
170
 
><code  class="code">convert_type</code></a></dt>
171
 
 
172
 
<dd>
173
 
<p>Converts a TYPE from the <a href="#ABSTRACT_SCHEMA" class="podlinkpod"
174
 
>&#34;ABSTRACT_SCHEMA&#34;</a> format into the real SQL type.</p>
175
 
 
176
 
<dt><a name="get_column($table,_$column)"
177
 
><code  class="code">get_column($table, $column)</code></a></dt>
178
 
 
179
 
<dd>
180
 
<pre  class="code"> Description: Public method to get the abstract definition of a column.
181
 
 Parameters:  $table - the table name
182
 
              $column - a column in the table
183
 
 Returns:     a hashref containing information about the column, including its
184
 
              type (C&#60;TYPE&#62;), whether or not it can be null (C&#60;NOTNULL&#62;),
185
 
              its default value if it has one (C&#60;DEFAULT), etc.
186
 
              Returns undef if the table or column does not exist.</pre>
187
 
 
188
 
<dt><a name="get_table_list"
189
 
><code  class="code">get_table_list</code></a></dt>
190
 
 
191
 
<dd>
192
 
<pre  class="code"> Description: Public method for discovering what tables should exist in the
193
 
              Bugzilla database.
194
 
 Parameters:  none
195
 
 Returns:     an array of table names</pre>
196
 
 
197
 
<dt><a name="get_table_columns"
198
 
><code  class="code">get_table_columns</code></a></dt>
199
 
 
200
 
<dd>
201
 
<pre  class="code"> Description: Public method for discovering what columns are in a given
202
 
              table in the Bugzilla database.
203
 
 Parameters:  $table - the table name
204
 
 Returns:     array of column names</pre>
205
 
 
206
 
<dt><a name="get_table_ddl"
207
 
><code  class="code">get_table_ddl</code></a></dt>
208
 
 
209
 
<dd>
210
 
<pre  class="code"> Description: Public method to generate the SQL statements needed to create
211
 
              the a given table and its indexes in the Bugzilla database.
212
 
              Subclasses may override or extend this method, if needed, but
213
 
              subclasses probably should override C&#60;_get_create_table_ddl&#62;
214
 
              or C&#60;_get_create_index_ddl&#62; instead.
215
 
 Parameters:  $table - the table name
216
 
 Returns:     an array of strings containing SQL statements</pre>
217
 
 
218
 
<dt><a name="_get_create_table_ddl"
219
 
><code  class="code">_get_create_table_ddl</code></a></dt>
220
 
 
221
 
<dd>
222
 
<pre  class="code"> Description: Protected method to generate the &#34;create table&#34; SQL statement
223
 
              for a given table.
224
 
 Parameters:  $table - the table name
225
 
 Returns:     a string containing the DDL statement for the specified table</pre>
226
 
 
227
 
<dt><a name="_get_create_index_ddl"
228
 
><code  class="code">_get_create_index_ddl</code></a></dt>
229
 
 
230
 
<dd>
231
 
<pre  class="code"> Description: Protected method to generate a &#34;create index&#34; SQL statement
232
 
              for a given table and index.
233
 
 Parameters:  $table_name - the name of the table
234
 
              $index_name - the name of the index
235
 
              $index_fields - a reference to an array of field names
236
 
              $index_type (optional) - specify type of index (e.g., UNIQUE)
237
 
 Returns:     a string containing the DDL statement</pre>
238
 
 
239
 
<dt><a name="get_add_column_ddl($table,_$column,_\%definition,_$init_value)"
240
 
><code  class="code">get_add_column_ddl($table, $column, \%definition, $init_value)</code></a></dt>
241
 
 
242
 
<dd>
243
 
<pre  class="code"> Description: Generate SQL to add a column to a table.
244
 
 Params:      $table - The table containing the column.
245
 
              $column - The name of the column being added.
246
 
              \%definition - The new definition for the column,
247
 
                  in standard C&#60;ABSTRACT_SCHEMA&#62; format.
248
 
              $init_value - (optional) An initial value to set 
249
 
                            the column to. Should already be SQL-quoted
250
 
                            if necessary.
251
 
 Returns:     An array of SQL statements.</pre>
252
 
 
253
 
<dt><a name="get_add_index_ddl"
254
 
><code  class="code">get_add_index_ddl</code></a></dt>
255
 
 
256
 
<dd>
257
 
<pre  class="code"> Description: Gets SQL for creating an index.
258
 
              NOTE: Subclasses should not override this function. Instead,
259
 
              if they need to specify a custom CREATE INDEX statement, 
260
 
              they should override C&#60;_get_create_index_ddl&#62;
261
 
 Params:      $table - The name of the table the index will be on.
262
 
              $name  - The name of the new index.
263
 
              $definition - An index definition. Either a hashref 
264
 
                            with FIELDS and TYPE or an arrayref 
265
 
                            containing a list of columns.
266
 
 Returns:     An array of SQL statements that will create the 
267
 
              requested index.</pre>
268
 
 
269
 
<dt><a name="get_alter_column_ddl($table,_$column,_\%definition)"
270
 
><code  class="code">get_alter_column_ddl($table, $column, \%definition)</code></a></dt>
271
 
 
272
 
<dd>
273
 
<pre  class="code"> Description: Generate SQL to alter a column in a table.
274
 
              The column that you are altering must exist,
275
 
              and the table that it lives in must exist.
276
 
 Params:      $table - The table containing the column.
277
 
              $column - The name of the column being changed.
278
 
              \%definition - The new definition for the column,
279
 
                  in standard C&#60;ABSTRACT_SCHEMA&#62; format.
280
 
              $set_nulls_to - A value to set NULL values to, if
281
 
                  your new definition is NOT NULL and contains
282
 
                  no DEFAULT, and when there is a possibility
283
 
                  that the column could contain NULLs. $set_nulls_to
284
 
                  should be already SQL-quoted if necessary.
285
 
 Returns:     An array of SQL statements.</pre>
286
 
 
287
 
<dt><a name="get_drop_index_ddl($table,_$name)"
288
 
><code  class="code">get_drop_index_ddl($table, $name)</code></a></dt>
289
 
 
290
 
<dd>
291
 
<pre  class="code"> Description: Generates SQL statements to drop an index.
292
 
 Params:      $table - The table the index is on.
293
 
              $name  - The name of the index being dropped.
294
 
 Returns:     An array of SQL statements.</pre>
295
 
 
296
 
<dt><a name="get_drop_column_ddl($table,_$column)"
297
 
><code  class="code">get_drop_column_ddl($table, $column)</code></a></dt>
298
 
 
299
 
<dd>
300
 
<pre  class="code"> Description: Generate SQL to drop a column from a table.
301
 
 Params:      $table - The table containing the column.
302
 
              $column - The name of the column being dropped.
303
 
 Returns:     An array of SQL statements.</pre>
304
 
 
305
 
<dt><a name="get_drop_table_ddl($table)"
306
 
><code  class="code">get_drop_table_ddl($table)</code></a></dt>
307
 
 
308
 
<dd>
309
 
<pre  class="code"> Description: Generate SQL to drop a table from the database.
310
 
 Params:      $table - The name of the table to drop.
311
 
 Returns:     An array of SQL statements.</pre>
312
 
 
313
 
<dt><a name="get_rename_column_ddl($table,_$old_name,_$new_name)"
314
 
><code  class="code">get_rename_column_ddl($table, $old_name, $new_name)</code></a></dt>
315
 
 
316
 
<dd>
317
 
<pre  class="code"> Description: Generate SQL to change the name of a column in a table.
318
 
              NOTE: ANSI SQL contains no simple way to rename a column,
319
 
                    so this function is ABSTRACT and must be implemented
320
 
                    by subclasses.
321
 
 Params:      $table - The table containing the column to be renamed.
322
 
              $old_name - The name of the column being renamed.
323
 
              $new_name - The name the column is changing to.
324
 
 Returns:     An array of SQL statements.</pre>
325
 
 
326
 
<dt><a name="get_rename_table_sql"
327
 
><code  class="code">get_rename_table_sql</code></a></dt>
328
 
 
329
 
<dd>
330
 
<dl>
331
 
<dt><a name="Description"
332
 
><b>Description</b></a></dt>
333
 
 
334
 
<dd>
335
 
<p>Gets SQL to rename a table in the database.</p>
336
 
 
337
 
<dt><a name="Params"
338
 
><b>Params</b></a></dt>
339
 
 
340
 
<dd>
341
 
<dl>
342
 
<dt><a name="$old_name_-_The_current_name_of_the_table."
343
 
><code  class="code">$old_name</code> - The current name of the table.
344
 
<dt><a name="$new_name_-_The_new_name_of_the_table."
345
 
><code  class="code">$new_name</code> - The new name of the table.</a></dt>
346
 
</dl>
347
 
 
348
 
<dt><a name="Returns:_An_array_of_SQL_statements_to_rename_a_table."
349
 
><b>Returns</b>: An array of SQL statements to rename a table.</a></dt>
350
 
</dl>
351
 
 
352
 
<dt><a name="delete_table($name)"
353
 
><code  class="code">delete_table($name)</code></a></dt>
354
 
 
355
 
<dd>
356
 
<pre  class="code"> Description: Deletes a table from this Schema object.
357
 
              Dies if you try to delete a table that doesn&#39;t exist.
358
 
 Params:      $name - The name of the table to delete.
359
 
 Returns:     nothing</pre>
360
 
 
361
 
<dt><a name="get_column_abstract($table,_$column)"
362
 
><code  class="code">get_column_abstract($table, $column)</code></a></dt>
363
 
 
364
 
<dd>
365
 
<pre  class="code"> Description: A column definition from the abstract internal schema.
366
 
              cross-database format.
367
 
 Params:      $table - The name of the table
368
 
              $column - The name of the column that you want
369
 
 Returns:     A hash reference. For the format, see the docs for
370
 
              C&#60;ABSTRACT_SCHEMA&#62;.
371
 
              Returns undef if the column or table does not exist.</pre>
372
 
 
373
 
<dt><a name="get_indexes_on_column_abstract($table,_$column)"
374
 
><code  class="code">get_indexes_on_column_abstract($table, $column)</code></a></dt>
375
 
 
376
 
<dd>
377
 
<pre  class="code"> Description: Gets a list of indexes that are on a given column.
378
 
 Params:      $table - The table the column is on.
379
 
              $column - The name of the column.
380
 
 Returns:     Indexes in the standard format of an INDEX
381
 
              entry on a table. That is, key-value pairs
382
 
              where the key is the index name and the value
383
 
              is the index definition.
384
 
              If there are no indexes on that column, we return
385
 
              undef.</pre>
386
 
 
387
 
<dt><a name="get_index_abstract($table,_$index)"
388
 
><code  class="code">get_index_abstract($table, $index)</code></a></dt>
389
 
 
390
 
<dd>
391
 
<pre  class="code"> Description: Returns an index definition from the internal abstract schema.
392
 
 Params:      $table - The table the index is on.
393
 
              $index - The name of the index.
394
 
 Returns:     A hash reference representing an index definition.
395
 
              See the C&#60;ABSTRACT_SCHEMA&#62; docs for details.
396
 
              Returns undef if the index does not exist.</pre>
397
 
 
398
 
<dt><a name="get_table_abstract($table)"
399
 
><code  class="code">get_table_abstract($table)</code></a></dt>
400
 
 
401
 
<dd>
402
 
<pre  class="code"> Description: Gets the abstract definition for a table in this Schema
403
 
              object.
404
 
 Params:      $table - The name of the table you want a definition for.
405
 
 Returns:     An abstract table definition, or undef if the table doesn&#39;t
406
 
              exist.</pre>
407
 
 
408
 
<dt><a name="add_table($name,_\%definition)"
409
 
><code  class="code">add_table($name, \%definition)</code></a></dt>
410
 
 
411
 
<dd>
412
 
<pre  class="code"> Description: Creates a new table in this Schema object.
413
 
              If you do not specify a definition, we will
414
 
              simply create an empty table.
415
 
 Params:      $name - The name for the new table.
416
 
              \%definition (optional) - An abstract definition for
417
 
                  the new table.
418
 
 Returns:     nothing</pre>
419
 
 
420
 
<dt><a name="rename_table"
421
 
><code  class="code">rename_table</code></a></dt>
422
 
 
423
 
<dd>
424
 
<p>Renames a table from <code  class="code">$old_name</code> to <code  class="code">$new_name</code> in this Schema object.</p>
425
 
 
426
 
<dt><a name="delete_column($table,_$column)"
427
 
><code  class="code">delete_column($table, $column)</code></a></dt>
428
 
 
429
 
<dd>
430
 
<pre  class="code"> Description: Deletes a column from this Schema object.
431
 
 Params:      $table - Name of the table that the column is in.
432
 
                       The table must exist, or we will fail.
433
 
              $column  - Name of the column to delete.
434
 
 Returns:     nothing</pre>
435
 
 
436
 
<dt><a name="rename_column($table,_$old_name,_$new_name)"
437
 
><code  class="code">rename_column($table, $old_name, $new_name)</code></a></dt>
438
 
 
439
 
<dd>
440
 
<pre  class="code"> Description: Renames a column on a table in the Schema object.
441
 
              The column that you are renaming must exist.
442
 
 Params:      $table - The table the column is on.
443
 
              $old_name - The current name of the column.
444
 
              $new_name - The new name of hte column.
445
 
 Returns:     nothing</pre>
446
 
 
447
 
<dt><a name="set_column($table,_$column,_\%new_def)"
448
 
><code  class="code">set_column($table, $column, \%new_def)</code></a></dt>
449
 
 
450
 
<dd>
451
 
<pre  class="code"> Description: Changes the definition of a column in this Schema object.
452
 
              If the column doesn&#39;t exist, it will be added.
453
 
              The table that you specify must already exist in the Schema.
454
 
              NOTE: This does not affect the database on the disk.
455
 
              Use the C&#60;Bugzilla::DB&#62; &#34;Schema Modification Methods&#34;
456
 
              if you want to do that.
457
 
 Params:      $table - The name of the table that the column is on.
458
 
              $column - The name of the column.
459
 
              \%new_def - The new definition for the column, in 
460
 
                  C&#60;ABSTRACT_SCHEMA&#62; format.
461
 
 Returns:     nothing</pre>
462
 
 
463
 
<dt><a name="set_index($table,_$name,_$definition)"
464
 
><code  class="code">set_index($table, $name, $definition)</code></a></dt>
465
 
 
466
 
<dd>
467
 
<pre  class="code"> Description: Changes the definition of an index in this Schema object.
468
 
              If the index doesn&#39;t exist, it will be added.
469
 
              The table that you specify must already exist in the Schema.
470
 
              NOTE: This does not affect the database on the disk.
471
 
              Use the C&#60;Bugzilla::DB&#62; &#34;Schema Modification Methods&#34;
472
 
              if you want to do that.
473
 
 Params:      $table      - The table the index is on.
474
 
              $name       - The name of the index.
475
 
              $definition - A hashref or an arrayref. An index 
476
 
                            definition in C&#60;ABSTRACT_SCHEMA&#62; format.
477
 
 Returns:     nothing</pre>
478
 
 
479
 
<dt><a name="delete_index($table,_$name)"
480
 
><code  class="code">delete_index($table, $name)</code></a></dt>
481
 
 
482
 
<dd>
483
 
<pre  class="code"> Description: Removes an index definition from this Schema object.
484
 
              If the index doesn&#39;t exist, we will fail.
485
 
              The table that you specify must exist in the Schema.
486
 
              NOTE: This does not affect the database on the disk.
487
 
              Use the C&#60;Bugzilla::DB&#62; &#34;Schema Modification Methods&#34;
488
 
              if you want to do that.
489
 
 Params:      $table - The table the index is on.
490
 
              $name  - The name of the index that we&#39;re removing.
491
 
 Returns:     nothing</pre>
492
 
 
493
 
<dt><a name="columns_equal($col_one,_$col_two)"
494
 
><code  class="code">columns_equal($col_one, $col_two)</code></a></dt>
495
 
 
496
 
<dd>
497
 
<pre  class="code"> Description: Tells you if two columns have entirely identical definitions.
498
 
              The TYPE field&#39;s value will be compared case-insensitive.
499
 
              However, all other fields will be case-sensitive.
500
 
 Params:      $col_one, $col_two - The columns to compare. Hash 
501
 
                  references, in C&#60;ABSTRACT_SCHEMA&#62; format.
502
 
 Returns:     C&#60;1&#62; if the columns are identical, C&#60;0&#62; if they are not.</pre>
503
 
</dd>
504
 
</dl>
505
 
 
506
 
<h1><a class='u' href='#___top' title='click to go to top of document'
507
 
name="SERIALIZATION/DESERIALIZATION"
508
 
>SERIALIZATION/DESERIALIZATION</a></h1>
509
 
 
510
 
<dl>
511
 
<dt><a name="serialize_abstract()"
512
 
><code  class="code">serialize_abstract()</code></a></dt>
513
 
 
514
 
<dd>
515
 
<pre  class="code"> Description: Serializes the &#34;abstract&#34; schema into a format
516
 
              that deserialize_abstract() can read in. This is
517
 
              a method, called on a Schema instance.
518
 
 Parameters:  none
519
 
 Returns:     A scalar containing the serialized, abstract schema.
520
 
              Do not attempt to manipulate this data directly,
521
 
              as the format may change at any time in the future.
522
 
              The only thing you should do with the returned value
523
 
              is either store it somewhere (coupled with appropriate 
524
 
              SCHEMA_VERSION) or deserialize it.</pre>
525
 
 
526
 
<dt><a name="deserialize_abstract($serialized,_$version)"
527
 
><code  class="code">deserialize_abstract($serialized, $version)</code></a></dt>
528
 
 
529
 
<dd>
530
 
<pre  class="code"> Description: Used for when you&#39;ve read a serialized Schema off the disk,
531
 
              and you want a Schema object that represents that data.
532
 
 Params:      $serialized - scalar. The serialized data.
533
 
              $version - A number in the format X.YZ. The &#34;version&#34;
534
 
                  of the Schema that did the serialization.
535
 
                  See the docs for C&#60;SCHEMA_VERSION&#62; for more details.
536
 
 Returns:     A Schema object. It will have the methods of (and work 
537
 
              in the same fashion as) the current version of Schema. 
538
 
              However, it will represent the serialized data instead of
539
 
              ABSTRACT_SCHEMA.</pre>
540
 
</dd>
541
 
</dl>
542
 
 
543
 
<h1><a class='u' href='#___top' title='click to go to top of document'
544
 
name="CLASS_METHODS"
545
 
>CLASS METHODS</a></h1>
546
 
 
547
 
<p>These methods are generally called on the class instead of on a specific object.</p>
548
 
 
549
 
<dl>
550
 
<dt><a name="get_empty_schema()"
551
 
><code  class="code">get_empty_schema()</code></a></dt>
552
 
 
553
 
<dd>
554
 
<pre  class="code"> Description: Returns a Schema that has no tables. In effect, this
555
 
              Schema is totally &#34;empty.&#34;
556
 
 Params:      none
557
 
 Returns:     A &#34;empty&#34; Schema object.</pre>
558
 
</dd>
559
 
</dl>
560
 
 
561
 
<h1><a class='u' href='#___top' title='click to go to top of document'
562
 
name="ABSTRACT_DATA_TYPES"
563
 
>ABSTRACT DATA TYPES</a></h1>
564
 
 
565
 
<p>The size and range data provided here is only intended as a guide. See your database&#39;s Bugzilla module (in this directory) for the most up-to-date values for these data types. The following abstract data types are used:</p>
566
 
 
567
 
<dl>
568
 
<dt><a name="BOOLEAN"
569
 
><code  class="code">BOOLEAN</code></a></dt>
570
 
 
571
 
<dd>
572
 
<p>Logical value 0 or 1 where 1 is true, 0 is false.</p>
573
 
 
574
 
<dt><a name="INT1"
575
 
><code  class="code">INT1</code></a></dt>
576
 
 
577
 
<dd>
578
 
<p>Integer values (-128 - 127 or 0 - 255 unsigned).</p>
579
 
 
580
 
<dt><a name="INT2"
581
 
><code  class="code">INT2</code></a></dt>
582
 
 
583
 
<dd>
584
 
<p>Integer values (-32,768 - 32767 or 0 - 65,535 unsigned).</p>
585
 
 
586
 
<dt><a name="INT3"
587
 
><code  class="code">INT3</code></a></dt>
588
 
 
589
 
<dd>
590
 
<p>Integer values (-8,388,608 - 8,388,607 or 0 - 16,777,215 unsigned)</p>
591
 
 
592
 
<dt><a name="INT4"
593
 
><code  class="code">INT4</code></a></dt>
594
 
 
595
 
<dd>
596
 
<p>Integer values (-2,147,483,648 - 2,147,483,647 or 0 - 4,294,967,295 unsigned)</p>
597
 
 
598
 
<dt><a name="SMALLSERIAL"
599
 
><code  class="code">SMALLSERIAL</code></a></dt>
600
 
 
601
 
<dd>
602
 
<p>An auto-increment <a href="#INT1" class="podlinkpod"
603
 
>&#34;INT1&#34;</a></p>
604
 
 
605
 
<dt><a name="MEDIUMSERIAL"
606
 
><code  class="code">MEDIUMSERIAL</code></a></dt>
607
 
 
608
 
<dd>
609
 
<p>An auto-increment <a href="#INT3" class="podlinkpod"
610
 
>&#34;INT3&#34;</a></p>
611
 
 
612
 
<dt><a name="INTSERIAL"
613
 
><code  class="code">INTSERIAL</code></a></dt>
614
 
 
615
 
<dd>
616
 
<p>An auto-increment <a href="#INT4" class="podlinkpod"
617
 
>&#34;INT4&#34;</a></p>
618
 
 
619
 
<dt><a name="TINYTEXT"
620
 
><code  class="code">TINYTEXT</code></a></dt>
621
 
 
622
 
<dd>
623
 
<p>Variable length string of characters up to 255 (2^8 - 1) characters wide or more depending on the character set used.</p>
624
 
 
625
 
<dt><a name="MEDIUMTEXT"
626
 
><code  class="code">MEDIUMTEXT</code></a></dt>
627
 
 
628
 
<dd>
629
 
<p>Variable length string of characters up to 16M (2^24 - 1) characters wide or more depending on the character set used.</p>
630
 
 
631
 
<dt><a name="TEXT"
632
 
><code  class="code">TEXT</code></a></dt>
633
 
 
634
 
<dd>
635
 
<p>Variable length string of characters up to 64K (2^16 - 1) characters wide or more depending on the character set used.</p>
636
 
 
637
 
<dt><a name="LONGBLOB"
638
 
><code  class="code">LONGBLOB</code></a></dt>
639
 
 
640
 
<dd>
641
 
<p>Variable length string of binary data up to 4M (2^32 - 1) bytes wide</p>
642
 
 
643
 
<dt><a name="DATETIME"
644
 
><code  class="code">DATETIME</code></a></dt>
645
 
 
646
 
<dd>
647
 
<p>DATETIME support varies from database to database, however, it&#39;s generally safe to say that DATETIME entries support all date/time combinations greater than 1900-01-01 00:00:00. Note that the format used is <code  class="code">YYYY-MM-DD hh:mm:ss</code> to be safe, though it&#39;s possible that your database may not require leading zeros. For greatest compatibility, however, please make sure dates are formatted as above for queries to guarantee consistent results.</p>
648
 
</dd>
649
 
</dl>
650
 
 
651
 
<p>Database-specific subclasses should define the implementation for these data types as a hash reference stored internally in the schema object as <code  class="code">db_specific</code>. This is typically done in overridden <a href="../../_initialize.html" class="podlinkpod"
652
 
>_initialize</a> method.</p>
653
 
 
654
 
<p>The following abstract boolean values should also be defined on a database-specific basis:</p>
655
 
 
656
 
<dl>
657
 
<dt><a name="TRUE"
658
 
><code  class="code">TRUE</code>
659
 
<dt><a name="FALSE"
660
 
><code  class="code">FALSE</code></a></dt>
661
 
</dl>
662
 
 
663
 
<h1><a class='u' href='#___top' title='click to go to top of document'
664
 
name="SEE_ALSO"
665
 
>SEE ALSO</a></h1>
666
 
 
667
 
<p><a href="../../Bugzilla/DB.html" class="podlinkpod"
668
 
>Bugzilla::DB</a></p>
669
 
 
670
 
<p><a href="http://www.bugzilla.org/docs/developer.html#sql-schema" class="podlinkurl"
671
 
>http://www.bugzilla.org/docs/developer.html#sql-schema</a></p>
672
 
<p class="backlinkbottom"><b><a name="___bottom" href="../../index.html" title="All Documents">&lt;&lt;</a></b></p>
673
 
 
674
 
<!-- end doc -->
675
 
 
676
 
</body></html>