Skip to content

Commit

Permalink
Fix old bitbucket2 creating migtaion
Browse files Browse the repository at this point in the history
  • Loading branch information
taras committed Jul 29, 2019
1 parent 23c52ef commit c86f884
Showing 1 changed file with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,21 @@ function (Blueprint $t) {
$t->text('token')->nullable();
}
);
DB::table('service')->where('service.type', '=', 'bitbucket')
->update(['service.type' => 'bitbucket2']);
$bitbucket_config_data = DB::table("bitbucket_config")->get();
foreach($bitbucket_config_data as $bitbucket_record){
if(!(DB::table('bitbucket2_config')->where('service_id', '=', $bitbucket_record->service_id)->get()->count() > 0)){
DB::table('bitbucket2_config')->insert([
'service_id' => $bitbucket_record->service_id,
'vendor' => $bitbucket_record->vendor,
'username' => $bitbucket_record->username,
'password' => $bitbucket_record->password,
'token' => $bitbucket_record->token,
]);
}
}
DB::table("bitbucket_config")->delete();
}

/**
Expand All @@ -33,6 +48,21 @@ function (Blueprint $t) {
*/
public function down()
{
$bitbucket2_config_data = DB::table("bitbucket2_config")->get();
foreach($bitbucket2_config_data as $bitbucket_record){
if (!(DB::table('bitbucket_config')->where('service_id', '=', $bitbucket_record->service_id)->get()->count() > 0)) {
DB::table('bitbucket_config')->insert([
'service_id' => $bitbucket_record->service_id,
'vendor' => $bitbucket_record->vendor,
'username' => $bitbucket_record->username,
'password' => $bitbucket_record->password,
'token' => $bitbucket_record->token,
]);
}
}
DB::table('service')->where('service.type', '=', 'bitbucket2')
->update(['service.type' => 'bitbucket']);
DB::table("bitbucket2_config")->delete();
Schema::dropIfExists('bitbucket2_config');
}
}

0 comments on commit c86f884

Please sign in to comment.