Phil Sturgeon | 9758d84 | 2011-02-07 20:39:00 +0000 | [diff] [blame] | 1 | <?php defined('BASEPATH') OR exit('No direct script access allowed');
|
| 2 |
|
| 3 | class Migration_Create_accounts extends CI_Migration {
|
| 4 |
|
| 5 | function up()
|
| 6 | {
|
| 7 | if ( ! $this->db->table_exists('accounts'))
|
| 8 | {
|
| 9 | // Setup Keys
|
| 10 | $this->dbforge->add_key('id', TRUE);
|
| 11 |
|
| 12 | $this->dbforge->add_field(array(
|
| 13 | 'id' => array('type' => 'INT', 'constraint' => 5, 'unsigned' => TRUE, 'auto_increment' => TRUE),
|
| 14 | 'company_name' => array('type' => 'VARCHAR', 'constraint' => '200', 'null' => FALSE),
|
| 15 | 'first_name' => array('type' => 'VARCHAR', 'constraint' => '200', 'null' => FALSE),
|
| 16 | 'last_name' => array('type' => 'VARCHAR', 'constraint' => '200', 'null' => FALSE),
|
| 17 | 'phone' => array('type' => 'TEXT', 'null' => FALSE),
|
| 18 | 'email' => array('type' => 'TEXT', 'null' => FALSE),
|
| 19 | 'address' => array('type' => 'TEXT', 'null' => FALSE),
|
| 20 | 'Last_Update' => array('type' => 'DATETIME', 'null' => FALSE)
|
| 21 | ));
|
| 22 |
|
| 23 | $this->dbforge->add_field("Created_At TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP");
|
| 24 | $this->dbforge->create_table('accounts', TRUE);
|
| 25 | }
|
| 26 | }
|
| 27 |
|
| 28 | function down()
|
| 29 | {
|
| 30 | $this->dbforge->drop_table('accounts');
|
| 31 | }
|
| 32 | }
|