Skip to content

Commit

Permalink
Fixed migration class to remove prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
Sammaye committed Aug 6, 2014
1 parent 10e84e2 commit cc9fd9c
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions migrations/m110517_155003_create_tables_audit_trail.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ class m110517_155003_create_tables_audit_trail extends CDbMigration
*/
public function up()
{

$prefix = $this->getDbConnection()->tablePrefix;

//Create our first version of the audittrail table
//Please note that this matches the original creation of the
//table from version 1 of the extension. Other migrations will
//upgrade it from here if we ever need to. This was done so
//that older versions can still use migrate functionality to upgrade.
$this->createTable( 'tbl_audit_trail',
$this->createTable($prefix . "audit_trail",
array(
'id' => 'pk',
'old_value' => 'text',
Expand All @@ -29,23 +30,24 @@ public function up()
);

//Index these bad boys for speedy lookups
$this->createIndex( 'idx_audit_trail_user_id', 'tbl_audit_trail', 'user_id');
$this->createIndex( 'idx_audit_trail_model_id', 'tbl_audit_trail', 'model_id');
$this->createIndex( 'idx_audit_trail_model', 'tbl_audit_trail', 'model');
$this->createIndex( 'idx_audit_trail_field', 'tbl_audit_trail', 'field');
$this->createIndex( 'idx_audit_trail_user_id', $prefix . "audit_trail", 'user_id');
$this->createIndex( 'idx_audit_trail_model_id', $prefix . "audit_trail", 'model_id');
$this->createIndex( 'idx_audit_trail_model', $prefix . "audit_trail", 'model');
$this->createIndex( 'idx_audit_trail_field', $prefix . "audit_trail", 'field');
/* http://stackoverflow.com/a/1827099/383478
$this->createIndex( 'idx_audit_trail_old_value', 'tbl_audit_trail', 'old_value');
$this->createIndex( 'idx_audit_trail_new_value', 'tbl_audit_trail', 'new_value');
*/
$this->createIndex( 'idx_audit_trail_action', 'tbl_audit_trail', 'action');
$this->createIndex( 'idx_audit_trail_action', $prefix . "audit_trail", 'action');
}

/**
* Drops the audit trail table
*/
public function down()
{
$this->dropTable( 'tbl_audit_trail' );
$prefix = $this->getDbConnection()->tablePrefix;
$this->dropTable( $prefix . "audit_trail" );
}

/**
Expand Down

0 comments on commit cc9fd9c

Please sign in to comment.