Skip to content

Commit

Permalink
Merge pull request #5 from dreamfactorysoftware/remove-old-api-bitbucket
Browse files Browse the repository at this point in the history
Remove bitbucked service for deprecated Bitbucket API
  • Loading branch information
Taras Viyatyk authored Jul 31, 2019
2 parents 68989a6 + c86f884 commit b6c7fb2
Show file tree
Hide file tree
Showing 11 changed files with 242 additions and 506 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');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class RenameServiceTypeFromBitbucket2ToBitbucket extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
DB::table('service')->where('service.type', '=', 'bitbucket2')
->update(['service.type' => 'bitbucket']);
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
DB::table('service')->where('service.type', '=', 'bitbucket')
->update(['service.type' => 'bitbucket2']);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class MoveDataFromBitbucket2ConfigTableIntoBitbucketConfigTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
$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("bitbucket2_config")->delete();
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
$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();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class RemoveBitbucket2ConfigTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::dropIfExists('bitbucket2_config');
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::create(
'bitbucket2_config',
function (Blueprint $t) {
$t->integer('service_id')->unsigned()->primary();
$t->foreign('service_id')->references('id')->on('service')->onDelete('cascade');
$t->string('vendor');
$t->string('username')->nullable();
$t->text('password')->nullable();
$t->text('token')->nullable();
}
);
}
}
Loading

0 comments on commit b6c7fb2

Please sign in to comment.