Skip to content

Commit

Permalink
Fixes #1174 - broken migration if asset_logs table has uploads
Browse files Browse the repository at this point in the history
  • Loading branch information
snipe committed Sep 15, 2015
1 parent d79e2a0 commit 39f82e5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,35 +63,39 @@ class AddThreadIdToAssetLogsTable extends Migration
public function up()
{

Schema::table( 'asset_logs', function ( Blueprint $table ) {
if (!Schema::hasColumn('asset_logs', 'thread_id')) {

$table->integer( 'thread_id' )
->nullable()
->default( null );
$table->index( 'thread_id' );
} );
Schema::table( 'asset_logs', function ( Blueprint $table ) {

$this->actionlog = new Actionlog();
$this->assetLogs = $this->actionlog->getListingOfActionLogsChronologicalOrder();
$table->integer( 'thread_id' )
->nullable()
->default( null );
$table->index( 'thread_id' );
} );

foreach ($this->assetLogs as $assetLog) {

if ($this->hasAssetChanged( $assetLog )) {
$this->resetCurrentAssetInformation( $assetLog );
}
$this->actionlog = new Actionlog();
$this->assetLogs = $this->actionlog->getListingOfActionLogsChronologicalOrder();

if ($this->hasBegunNewChain( $assetLog )) {
$this->startOfCurrentThread = false;
continue;
}
foreach ($this->assetLogs as $assetLog) {

$this->updateAssetLogWithThreadInformation( $assetLog );
if ($this->hasAssetChanged( $assetLog )) {
$this->resetCurrentAssetInformation( $assetLog );
}

if ($this->hasReachedEndOfChain( $assetLog )
) {
$this->clearCurrentAssetInformation();
}
if ($this->hasBegunNewChain( $assetLog )) {
$this->startOfCurrentThread = false;
continue;
}

$this->updateAssetLogWithThreadInformation( $assetLog );

if ($this->hasReachedEndOfChain( $assetLog )
) {
$this->clearCurrentAssetInformation();
}

}
}

}
Expand Down
1 change: 1 addition & 0 deletions app/models/Actionlog.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ public function getListingOfActionLogsChronologicalOrder()

return DB::table( 'asset_logs' )
->select( '*' )
->where('action_type','!=','uploaded')
->orderBy( 'asset_id', 'asc' )
->orderBy( 'created_at', 'asc' )
->get();
Expand Down

0 comments on commit 39f82e5

Please sign in to comment.