/**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     Schema::connection('ff-actions-calc')->drop('terminals');
     Schema::connection('ff-actions-calc')->drop('events');
     Schema::connection('ff-actions-calc')->drop('rules');
     Schema::connection('ff-actions-calc')->drop('signals');
 }
 public function testArtisanRefresh()
 {
     $this->executeDefaultMigration()->call('migrate:refresh', array('--type' => $this->testType));
     $this->resetLaravelPaths();
     $this->assertTrue(Schema::connection('artisantest_' . $this->testType)->hasTable('test_tbl'));
     $entry = $this->app['db']->connection('artisantest_' . $this->testType)->table('test_tbl')->where('id', 1)->first();
     $this->assertEquals($this->testType, $entry->test_val);
 }
 /**
  * Create Table Schema.
  *
  * @param  \Closure  $blueprint
  */
 protected function createSchema(Closure $blueprint)
 {
     if (!$this->hasConnection()) {
         Schema::create($this->getTableName(), $blueprint);
         return;
     }
     Schema::connection($this->connection)->create($this->getTableName(), $blueprint);
 }
 /**
  * Run the migrations.
  */
 public function up()
 {
     Schema::connection($this->connection)->create($this->table, function (Blueprint $table) {
         $table->string('email')->index();
         $table->string('token')->index();
         $table->timestamp('created_at')->nullable();
     });
 }
 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     Schema::connection('ff-qiwi-gate')->table('merchants_bills', function (Blueprint $table) {
         $table->dropColumn('lifetime');
     });
     Schema::connection('ff-qiwi-gate')->table('merchants_bills', function (Blueprint $table) {
         $table->string('lifetime')->after('comment');
     });
 }
 /**
  * Run the migrations.
  */
 public function up()
 {
     Schema::connection($this->connection)->create($this->table, function (Blueprint $table) {
         $table->integer('permission_id')->unsigned();
         $table->integer('role_id')->unsigned();
         $table->timestamps();
         $table->primary(['permission_id', 'role_id']);
     });
 }
 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     Schema::connection('ff-qiwi-shop')->table('orders', function (Blueprint $table) {
         $table->dropColumn('lifetime');
     });
     Schema::connection('ff-qiwi-shop')->table('orders', function (Blueprint $table) {
         $table->string('lifetime')->after('comment');
     });
 }
 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     Schema::connection('ff-qiwi-shop')->drop('orders_pay_return');
     Schema::connection('ff-qiwi-shop')->table('orders', function (Blueprint $table) {
         $table->string('statusReturn')->nullable()->after('status')->default(null);
     });
     Schema::connection('ff-qiwi-shop')->table('orders', function (Blueprint $table) {
         $table->dropColumn('idLastReturn');
     });
 }
 /**
  * Run the migrations.
  */
 public function up()
 {
     Schema::connection($this->connection)->create($this->table, function (Blueprint $table) {
         $table->increments('id');
         $table->string('name');
         $table->string('slug');
         $table->string('description')->nullable();
         $table->timestamps();
         $table->unique('slug');
     });
 }
Ejemplo n.º 10
0
 /**
  * Check if we need to run the schema
  * @return [type] [description]
  */
 public static function executeSchema()
 {
     $schema = Schema::connection('mysql');
     if (!$schema->hasTable('users')) {
         Schema::connection('mysql')->create('users', function ($table) {
             $table->increments('id');
             $table->string('name');
             $table->timestamps();
         });
     }
 }
Ejemplo n.º 11
0
 /**
  * Check if we need to run the schema
  * @return [type] [description]
  */
 public static function executeSchema()
 {
     $schema = Schema::connection('mysql');
     if (!$schema->hasTable('books')) {
         Schema::connection('mysql')->create('books', function ($table) {
             $table->string('title');
             $table->string('author_id');
             $table->timestamps();
         });
     }
 }
 /**
  * Run the migrations.
  */
 public function up()
 {
     if ($this->isThrottlable()) {
         Schema::connection($this->connection)->create($this->table, function (Blueprint $table) {
             $table->increments('id');
             $table->integer('user_id')->unsigned()->nullable();
             $table->string('type');
             $table->string('ip')->nullable();
             $table->timestamps();
         });
     }
 }
Ejemplo n.º 13
0
 /**
  * Delete all database tables.
  */
 private function emptyDatabase()
 {
     if (!$this->option('empty-database')) {
         return;
     }
     $this->info("Truncating {$this->connection} database.");
     $tableNames = Schema::connection($this->connection)->getConnection()->getDoctrineSchemaManager()->listTableNames();
     DB::connection($this->connection)->statement($this->sql->setForeignKeyChecks(false));
     foreach ($tableNames as $table) {
         Schema::connection($this->connection)->drop($table);
     }
     DB::connection($this->connection)->statement($this->sql->setForeignKeyChecks(true));
 }
Ejemplo n.º 14
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $data = $request->all();
     $userFields = Schema::connection('mysql')->getColumnListing('users');
     if (isset($data)) {
         $user = User::find($data['id']);
         foreach ($data as $key => $value) {
             if (in_array($key, $userFields)) {
                 $user[$key] = $value;
             }
         }
         $user->save();
     }
     return response()->json(array('success' => 'true'));
 }
Ejemplo n.º 15
0
 /**
  * Create a new Local gateway instance.
  *
  * @return void
  */
 public function __construct($connection = null)
 {
     if (null === $connection) {
         $connection = config('billing.gateways.local');
     }
     $this->connection = $connection;
     \Config::set('database.connections.billinglocal', Arr::get($connection, 'database'));
     $path = Arr::get($connection, 'database.database');
     if (!file_exists($path) && is_dir(dirname($path))) {
         touch($path);
     }
     if (!Schema::connection('billinglocal')->hasTable('customers')) {
         include_once 'Models/migration.php';
     }
 }
Ejemplo n.º 16
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $data = $request->all();
     $noteFields = Schema::connection('mysql')->getColumnListing('notes');
     if (isset($data)) {
         $note = Note::find($id);
         if (in_array($data['name'], $noteFields)) {
             if ($this->utilityService->isDateField($data['name'])) {
                 $data['value'] = $this->utilityService->parseToMysqlDate($data['value']);
             }
             $note[$data['name']] = $data['value'];
         }
         $note->save();
     }
     return response()->json(array('note' => $note->toArray()));
 }
 /**
  * Run the migrations.
  */
 public function up()
 {
     Schema::connection($this->connection)->create($this->table, function (Blueprint $table) {
         $table->increments('id');
         $table->string('username');
         $table->string('first_name', 30)->nullable();
         $table->string('last_name', 30)->nullable();
         $this->addCredentialsColumns($table);
         $table->rememberToken();
         $table->boolean('is_admin')->default(0);
         $table->boolean('is_active')->default(0);
         $this->addConfirmationColumns($table);
         $table->timestamp('last_activity')->nullable();
         $table->timestamps();
         $table->softDeletes();
     });
 }
 /**
  * Run the migrations.
  */
 public function up()
 {
     Schema::connection($this->connection)->create($this->table, function (Blueprint $table) {
         $table->increments('id');
         $table->string('username');
         $table->string('first_name', 30)->nullable();
         $table->string('last_name', 30)->nullable();
         $table->string('email');
         $table->string('password', 60);
         $table->rememberToken();
         $table->boolean('is_admin')->default(0);
         $table->boolean('is_active')->default(0);
         if (UserConfirmator::isEnabled()) {
             $this->addConfirmationColumns($table);
         }
         $table->timestamps();
         $table->softDeletes();
         $table->unique('email');
     });
 }
 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     Schema::connection('ff-qiwi-gate')->drop('bills_refund');
 }
Ejemplo n.º 20
0
 /**
  * Dynamically add columns to the grid view.
  *
  * @param $method
  * @param $arguments
  *
  * @return $this|Column
  */
 public function __call($method, $arguments)
 {
     if ($this->model()->eloquent() instanceof MongodbModel) {
         $label = isset($arguments[0]) ? $arguments[0] : ucfirst($method);
         return $this->addColumn($method, $label);
     }
     $connection = $this->model()->eloquent()->getConnectionName();
     if (Schema::connection($connection)->hasColumn($this->model()->getTable(), $method)) {
         $label = isset($arguments[0]) ? $arguments[0] : ucfirst($method);
         return $this->addColumn($method, $label);
     }
     $relation = $this->model()->eloquent()->{$method}();
     if ($relation instanceof Relation) {
         $this->model()->with($method);
         return $this->addColumn()->setRelation($method);
     }
 }
Ejemplo n.º 21
0
 private function createPostcodifyTables()
 {
     Schema::connection('postcodify')->create('postcodify_addresses', function (Blueprint $table) {
         $table->increments('id');
         $table->decimal('address_id', 25, 0);
         $table->char('postcode5', 5);
         $table->char('postcode6', 6);
         $table->decimal('road_id', 14, 0);
         $table->smallInteger('num_major')->nullable();
         $table->smallInteger('num_minor')->nullable();
         $table->boolean('is_basement');
         $table->string('dongri_ko', 80);
         $table->string('dongri_en', 80);
         $table->smallInteger('jibeon_major');
         $table->smallInteger('jibeon_minor');
         $table->boolean('is_mountain');
         $table->integer('building_id', false, true)->nullable();
         $table->string('building_name', 80)->nullable();
         $table->string('other_addresses', 2000)->nullable();
         $table->decimal('updated', 8, 0)->nullable();
     });
     Schema::connection('postcodify')->create('postcodify_roads', function (Blueprint $table) {
         $table->decimal('road_id', 14, 0);
         $table->string('road_name_ko', 40)->nullable();
         $table->string('road_name_en', 40)->nullable();
         $table->string('sido_ko', 40)->nullable();
         $table->string('sido_en', 40)->nullable();
         $table->string('sigungu_ko', 40)->nullable();
         $table->string('sigungu_en', 40)->nullable();
         $table->string('ilbangu_ko', 40)->nullable();
         $table->string('ilbangu_en', 40)->nullable();
         $table->string('eupmyeon_ko', 40)->nullable();
         $table->string('eupmyeon_en', 40)->nullable();
     });
     Schema::connection('postcodify')->create('postcodify_buildings', function (Blueprint $table) {
         $table->integer('seq', false, true);
         $table->integer('address_id', false, true);
         $table->string('keyword', 120);
     });
     Schema::connection('postcodify')->create('postcodify_english', function (Blueprint $table) {
         $table->integer('seq');
         $table->string('ko', 40);
         $table->integer('ko_crc32', false, true);
         $table->string('en', 40);
         $table->integer('en_crc32', false, true);
     });
     Schema::connection('postcodify')->create('postcodify_keywords', function (Blueprint $table) {
         $table->integer('seq', false, true);
         $table->integer('address_id', false, true);
         $table->integer('keyword_crc32', false, true);
     });
     Schema::connection('postcodify')->create('postcodify_numbers', function (Blueprint $table) {
         $table->integer('seq', false, true);
         $table->integer('address_id', false, true);
         $table->smallInteger('num_major', false, true)->nullable();
         $table->smallInteger('num_minor', false, true)->nullable();
     });
     Schema::connection('postcodify')->create('postcodify_pobox', function (Blueprint $table) {
         $table->integer('seq', false, true);
         $table->integer('address_id', false, true);
         $table->string('keyword', 40);
         $table->smallInteger('range_start_major', false, true);
         $table->smallInteger('range_start_minor', false, true);
         $table->smallInteger('range_end_major', false, true);
         $table->smallInteger('range_end_minor', false, true);
     });
 }
 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     Schema::connection('ff-qiwi-gate')->table('merchants_bills', function (Blueprint $table) {
         $table->dropColumn('status');
     });
 }
Ejemplo n.º 23
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $data = $request->all();
     $victimFields = Schema::connection('mysql')->getColumnListing('victims');
     if (isset($data)) {
         $victim = Victim::find($data['id']);
         foreach ($data as $key => $value) {
             if (in_array($key, $victimFields)) {
                 if ($this->utilityService->isDateField($key)) {
                     $value = $this->utilityService->parseToMysqlDate($value);
                 }
                 $victim[$key] = $value;
             }
         }
         $victim->save();
         if (isset($data['cases'])) {
             $existingCases = $this->victimService->getVictimById($data['id'])->rjCases;
             foreach ($data['cases'] as $newCase) {
                 if (!in_array($newCase, $existingCases->toArray())) {
                     $victim->rjCases()->detach();
                 }
             }
             foreach ($data['cases'] as $newCase) {
                 $victim->rjCases()->attach($newCase);
             }
         }
     }
     return response()->json(array('success' => 'true'));
 }
Ejemplo n.º 24
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request)
 {
     $data = $request->all();
     $caseFields = Schema::connection('mysql')->getColumnListing('rj_cases');
     if (isset($data)) {
         $case = RjCase::find($data['id']);
         foreach ($data as $key => $value) {
             if (in_array($key, $caseFields)) {
                 if ($this->utilityService->isDateField($key)) {
                     $value = !empty($value) ? $this->utilityService->parseToMysqlDate($value) : null;
                 }
                 $case[$key] = $value;
             }
         }
         $case->save();
     }
     if (isset($data['victims'])) {
         $victimFields = Schema::connection('mysql')->getColumnListing('victims');
         foreach ($data['victims'] as $newVictim) {
             $victim = Victim::find($newVictim['id']);
             foreach ($newVictim as $key => $value) {
                 if (in_array($key, $victimFields)) {
                     if ($this->utilityService->isDateField($key)) {
                         $value = $this->utilityService->parseToMysqlDate($value);
                     }
                     $victim[$key] = $value;
                 }
             }
             $victim->save();
         }
     }
     if (isset($data['offenders'])) {
         $offenderFields = Schema::connection('mysql')->getColumnListing('offenders');
         foreach ($data['offenders'] as $newOffender) {
             $offender = Offender::find($newOffender['id']);
             foreach ($newOffender as $key => $value) {
                 if (in_array($key, $offenderFields)) {
                     if ($this->utilityService->isDateField($key)) {
                         $value = $this->utilityService->parseToMysqlDate($value);
                     }
                     $offender[$key] = $value;
                 }
             }
             $offender->save();
         }
     }
     if (isset($data['charges'])) {
         $existingCharges = RjCase::find($data['id'])->charges;
         foreach ($data['charges'] as $newCharge) {
             if (!in_array($newCharge, $existingCharges->toArray())) {
                 $case->charges()->detach();
             }
         }
         foreach ($data['charges'] as $newCharge) {
             $case->charges()->attach($newCharge);
         }
     }
     if (isset($data['facilitators'])) {
         $existingFacilitators = RjCase::find($data['id'])->users;
         foreach ($data['facilitators'] as $newFacilitator) {
             if (!in_array($newFacilitator, $existingFacilitators->toArray())) {
                 $case->users()->detach();
             }
         }
         foreach ($data['facilitators'] as $newFacilitator) {
             $case->users()->attach($newFacilitator);
         }
     }
     return response()->json(array('id' => $case->id));
 }
Ejemplo n.º 25
0
 /**
  * Create Table Schema.
  *
  * @param  \Closure  $blueprint
  */
 protected function createSchema(Closure $blueprint)
 {
     if ($this->hasConnection()) {
         Schema::connection($this->getConnection())->create($this->getTableName(), $blueprint);
     } else {
         Schema::create($this->getTableName(), $blueprint);
     }
 }
 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     Schema::connection('ff-qiwi-gate')->drop('merchants_bills');
 }
Ejemplo n.º 27
0
 public function autoUpdate($save = false)
 {
     $this->getValue();
     $this->getNewValue();
     if (is_object($this->model) && isset($this->db_name)) {
         if (!(Schema::connection($this->model->getConnectionName())->hasColumn($this->model->getTable(), $this->db_name) || $this->model->hasSetMutator($this->db_name)) || is_a($this->relation, 'Illuminate\\Database\\Eloquent\\Relations\\HasOne')) {
             $self = $this;
             //fix old 5.3 you can't pass this in a closure
             $this->model->saved(function () use($self) {
                 $self->updateRelations();
             });
             //check for relation then exit
             return true;
         }
         //if (isset($this->new_value)) {
         $this->model->setAttribute($this->db_name, $this->new_value);
         //} else {
         //    $this->model->setAttribute($this->db_name, $this->value);
         //}
         if ($save) {
             return $this->model->save();
         }
     }
     return true;
 }
 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     Schema::connection('ff-qiwi-shop')->table('orders', function (Blueprint $table) {
         $table->dropColumn('statusReturn');
     });
 }
Ejemplo n.º 29
0
 public function autoUpdate($save = false)
 {
     $this->getValue();
     $this->getNewValue();
     if (!$this->editable()) {
         return true;
     }
     if (is_object($this->model) && isset($this->db_name)) {
         if (!(Schema::connection($this->model->getConnectionName())->hasColumn($this->model->getTable(), $this->db_name) || $this->model->hasSetMutator($this->db_name)) || is_a($this->relation, 'Illuminate\\Database\\Eloquent\\Relations\\Relation')) {
             //belongsTo relation
             if (is_a($this->relation, 'Illuminate\\Database\\Eloquent\\Relations\\BelongsTo')) {
                 $this->model->setAttribute($this->db_name, $this->new_value);
                 return true;
             }
             //other kind of relations are postponed
             $self = $this;
             $this->model->saved(function () use($self) {
                 $self->updateRelations();
             });
             //check for relation then exit
             return true;
         }
         if (!is_a($this->relation, 'Illuminate\\Database\\Eloquent\\Relations\\Relation')) {
             $this->model->setAttribute($this->db_name, $this->new_value);
         }
         if ($save) {
             return $this->model->save();
         }
     }
     return true;
 }
Ejemplo n.º 30
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     if (Cache::get('isWorkerStarted', false)) {
         return;
     }
     if (!Cache::get('isProcessing', false)) {
         return;
     }
     Cache::forever('isWorkerStarted', true);
     set_time_limit(0);
     $skipTables = explode(',', env('SKIP_TABLES', ''));
     if (Cache::has('tables')) {
         $tables = Cache::get('tables');
     } else {
         $tables = ['pgsql' => [], 'mongodb' => []];
         $pgsqlTables = DB::connection('pgsql')->getDoctrineSchemaManager()->listTableNames();
         foreach ($pgsqlTables as $table) {
             $tables['pgsql'][] = str_replace('"', '', $table);
         }
         $tables['mongodb'] = DB::connection('mongodb')->getMongoDB()->getCollectionNames();
         Cache::put('tables', $tables, 15);
     }
     if (Cache::has('rows')) {
         $rows = Cache::get('rows');
     } else {
         $rows = ['pgsql' => [], 'mongodb' => []];
         foreach ($tables['pgsql'] as $table) {
             if (in_array($table, $skipTables)) {
                 $rows['pgsql'][$table] = 0;
                 continue;
             }
             $rows['pgsql'][$table] = DB::connection('pgsql')->table($table)->count();
         }
         foreach ($tables['mongodb'] as $table) {
             $rows['mongodb'][$table] = DB::connection('mongodb')->table($table)->raw(function ($collection) {
                 return $collection->count();
             });
         }
         Cache::put('rows', $rows, 15);
     }
     $runStartedAt = time();
     $wasWorking = false;
     while ($runStartedAt + 60 * 10 >= time()) {
         foreach ($tables['pgsql'] as $table) {
             if (!Schema::connection('mongodb')->hasCollection($table)) {
                 Schema::connection('mongodb')->create($table);
                 $tables['mongodb'][] = $table;
                 $rows['mongodb'][$table] = 0;
                 Cache::put('tables', $tables, 15);
                 Cache::put('rows', $rows, 15);
             }
             if (in_array($table, $skipTables)) {
                 continue;
             }
             if ($rows['pgsql'][$table] > $rows['mongodb'][$table]) {
                 $batchSize = 10000;
                 DB::connection('mongodb')->disableQueryLog();
                 DB::connection('pgsql')->disableQueryLog();
                 $data = DB::connection('pgsql')->table($table)->skip($rows['mongodb'][$table])->take($batchSize)->get();
                 $insert = json_decode(json_encode($data), true);
                 // Cast date fields to MongoDate objects
                 foreach ($insert as $key => $item) {
                     foreach ($item as $rowName => $value) {
                         if ($rowName == 'created_at' || $rowName == 'updated_at') {
                             $insert[$key][$rowName] = new MongoDate(strtotime($value));
                         }
                     }
                 }
                 DB::connection('mongodb')->table($table)->insert($insert);
                 $rows['mongodb'][$table] += $batchSize;
                 if ($rows['mongodb'][$table] > $rows['pgsql'][$table]) {
                     $rows['mongodb'][$table] = $rows['pgsql'][$table];
                 }
                 Cache::put('rows', $rows, 15);
                 Cache::increment('rowsProcessedThisRun', $batchSize);
                 $wasWorking = true;
                 break;
             }
         }
     }
     if ($wasWorking == false) {
         Cache::forever('timeFinished', Carbon::now());
         Cache::forever('isProcessing', false);
     }
     Cache::forever('isWorkerStarted', false);
 }