Replace “booklink” with your project name wherever it is found. Use the case structure in the example.
<?php class 8-o extends AkInstaller { function up_1(){ $this->createTable('books', // The table name must be plural. 'id,'. // This key must be in every table. 'col_1 string(10),'. // Columns have default characteristics. 'col_last' // The last column does not end with a "." ); } function down_1(){ $this->dropTables('books'); } } ?>
simple not bad… The column type options are
Or any column type that is supported by the database you’re using, like varchar or smallint on MySQL. One warning though: don not use tinyint on MySQL because it will be typecasted as boolean.
See http://phplens.com/lens/adodb/docs-datadict.htm to customize column options.
./script/migrate Booklink install.svn status?”, enter svn add <path>svn commit -m 'create books table' . Any comment may follow -m.
modifyTable($table_name, $column_options = null, $table_options = array()
No description
dropTable($table_name, $options = array())
No description
dropTables()
No description
getAvailableTables()
No description
tableExists($table_name)
No description
addColumn($table_name, $column_details)
Adds a new column to the table called $table_name
changeColumn($table_name, $column_details)
No description\
removeColumn($table_name, $column_name)
No description
renameColumn($table_name, $old_column_name, $new_column_name)
No description
getDefaultColumnAttributesRules()
Returns a key ⇒ value pair of regular expressions that will trigger methods
to cast database columns to their respective default values or a replacement expression.
addIndex($table_name, $columns, $index_name = '')
No description
removeIndex($table_name, $columns_or_index_name)
No description
dropIndex($table_name, $columns_or_index_name)
No description
createSequence($table_name)
No description
dropSequence($table_name)
No description
transactionStart()
Transaction support for database operations
transactionComplete()
No description
transactionFail()
No description
transactionHasFailed()
No description
promptUserVar($message, $options = array()
Promts for a variable on console scripts
execute($sql)
No description
debug($toggle = null)
No description
Transactions are enabled automatically for Installer objects. You can nest transactions within models. This transaction is nested. Only the outermost will be executed.
$UserInstalller->transactionStart(); $UserInstalller->addTable('id, name'); if(!isCompatible()){ $User->transactionFail(); } $User->transactionComplete();