From be56116baa78555f0be3c6257394868d0c0ec02d Mon Sep 17 00:00:00 2001 From: denghy Date: Fri, 21 Dec 2018 16:09:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E5=A4=87=E6=B3=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...018_08_08_170019_create_accounts_table.php | 5 +- ...2018_08_09_154046_create_configs_table.php | 4 +- .../2018_08_10_092334_create_file_tables.php | 8 +-- .../2018_08_14_142405_create_logs.php | 4 +- ..._08_08_170540_create_permission_tables.php | 16 ++--- composer.lock | 12 ++-- ..._11_16_190020_create_failed_jobs_table.php | 2 + .../2018_11_27_175137_create_base_tables.php | 41 ++++++------ .../2018_11_27_175146_create_order_tables.php | 5 +- ...018_11_27_175152_create_package_tables.php | 5 +- ..._12_170419_create_virtual_orders_table.php | 3 +- .../2018_12_21_134548_create_tests_table.php | 37 +++++++++++ vendor/composer/autoload_classmap.php | 1 + vendor/composer/autoload_static.php | 1 + vendor/composer/installed.json | 14 ++-- .../src/Database/DatabaseServiceProvider.php | 26 ++++++++ .../src/Database/MysqlSchemaGrammar.php | 30 +++++++++ .../src/Database/PostgresSchemaGrammar.php | 65 +++++++++++++++++++ 18 files changed, 221 insertions(+), 58 deletions(-) create mode 100644 database/migrations/2018_12_21_134548_create_tests_table.php diff --git a/app/Domains/Account/Database/migrations/2018_08_08_170019_create_accounts_table.php b/app/Domains/Account/Database/migrations/2018_08_08_170019_create_accounts_table.php index 266cc983..a94d502d 100644 --- a/app/Domains/Account/Database/migrations/2018_08_08_170019_create_accounts_table.php +++ b/app/Domains/Account/Database/migrations/2018_08_08_170019_create_accounts_table.php @@ -28,9 +28,10 @@ class CreateAccountsTable extends Migration $table->index('username'); $table->index('mobile'); - }); - db_alter('accounts', '平台账号', 100000); + $table->comment('平台账号'); + $table->setIncrement(100000); + }); } /** diff --git a/app/Domains/Config/Database/migrations/2018_08_09_154046_create_configs_table.php b/app/Domains/Config/Database/migrations/2018_08_09_154046_create_configs_table.php index 3db82749..c4cd7f26 100644 --- a/app/Domains/Config/Database/migrations/2018_08_09_154046_create_configs_table.php +++ b/app/Domains/Config/Database/migrations/2018_08_09_154046_create_configs_table.php @@ -18,9 +18,9 @@ class CreateConfigsTable extends Migration $table->text('value')->nullable()->comment('缓存值'); $table->timestamps(); $table->primary('name'); - }); - db_alter('configs', '配置表'); + $table->comment('配置表'); + }); } /** diff --git a/app/Domains/File/Database/migrations/2018_08_10_092334_create_file_tables.php b/app/Domains/File/Database/migrations/2018_08_10_092334_create_file_tables.php index 8f95178e..cdba960d 100644 --- a/app/Domains/File/Database/migrations/2018_08_10_092334_create_file_tables.php +++ b/app/Domains/File/Database/migrations/2018_08_10_092334_create_file_tables.php @@ -29,9 +29,9 @@ class CreateFileTables extends Migration $table->timestamps(); $table->primary('id'); - }); - db_alter('files', '文件表'); + $table->comment('文件表'); + }); // 文件关联表 Schema::create('file_withs', function (Blueprint $table) { @@ -46,9 +46,9 @@ class CreateFileTables extends Migration $table->index('file_id'); $table->index('account_id'); $table->index(['type', 'type_id']); - }); - db_alter('file_withs', '文件关联表'); + $table->comment('文件关联表'); + }); } /** diff --git a/app/Domains/Log/Database/migrations/2018_08_14_142405_create_logs.php b/app/Domains/Log/Database/migrations/2018_08_14_142405_create_logs.php index 34145594..8f649808 100644 --- a/app/Domains/Log/Database/migrations/2018_08_14_142405_create_logs.php +++ b/app/Domains/Log/Database/migrations/2018_08_14_142405_create_logs.php @@ -33,9 +33,9 @@ class CreateLogs extends Migration $table->timestamps(); $table->primary('id'); - }); - db_alter('logs', '日志表'); + $table->comment('日志表'); + }); } /** diff --git a/app/Domains/Permission/Database/migrations/2018_08_08_170540_create_permission_tables.php b/app/Domains/Permission/Database/migrations/2018_08_08_170540_create_permission_tables.php index afcc8319..62b10d10 100644 --- a/app/Domains/Permission/Database/migrations/2018_08_08_170540_create_permission_tables.php +++ b/app/Domains/Permission/Database/migrations/2018_08_08_170540_create_permission_tables.php @@ -28,9 +28,9 @@ class CreatePermissionTables extends Migration $table->tinyInteger('displayorder')->unsigned()->default(0)->comment('排序'); $table->nestedset(); $table->timestamps(); - }); - db_alter('permissions', '权限表'); + $table->comment('权限表'); + }); Schema::create('roles', function (Blueprint $table) { $table->increments('id'); @@ -39,25 +39,25 @@ class CreatePermissionTables extends Migration $table->nestedset(); $table->timestamps(); $table->unique(['name']); - }); - db_alter('roles', '角色表'); + $table->comment('角色表'); + }); Schema::create('account_has_roles', function (Blueprint $table) use ($tableNames) { $table->unsignedInteger('role_id'); $table->unsignedInteger('account_id'); $table->primary(['role_id', 'account_id']); - }); - db_alter('account_has_roles', '账号角色关联表'); + $table->comment('账号角色关联表'); + }); Schema::create('role_has_permissions', function (Blueprint $table) use ($tableNames) { $table->unsignedInteger('permission_id'); $table->unsignedInteger('role_id'); $table->primary(['permission_id', 'role_id']); - }); - db_alter('role_has_permissions', '角色权限关联表'); + $table->comment('角色权限关联表'); + }); } /** diff --git a/composer.lock b/composer.lock index 29aff089..a5862e77 100644 --- a/composer.lock +++ b/composer.lock @@ -626,17 +626,17 @@ }, { "name": "dipper/foundation", - "version": "1.1.8", + "version": "1.1.9", "source": { "type": "git", "url": "ssh://gogs@git.fxft.net:2222/composer/foundation.git", - "reference": "0010bd177e6a367285a6ff3401f265bc80ef32fb" + "reference": "94efaf5b1e21d1bc4f7bae4fc6c4d3f741b399d0" }, "dist": { "type": "tar", - "url": "https://composer.fxft.online/dist/dipper/foundation/dipper-foundation-1.1.8-30793d.tar", - "reference": "0010bd177e6a367285a6ff3401f265bc80ef32fb", - "shasum": "6839ae4c43c3f38f4fe2ca22a1cc06b75934debd" + "url": "https://composer.fxft.online/dist/dipper/foundation/dipper-foundation-1.1.9-51f1b8.tar", + "reference": "94efaf5b1e21d1bc4f7bae4fc6c4d3f741b399d0", + "shasum": "b17959dd9990df31f7e6c3cff53749afe151f670" }, "require": { "barryvdh/laravel-cors": "~0.11", @@ -670,7 +670,7 @@ } ], "description": "The Foundation of the Dipper Architecture project for Lumen", - "time": "2018-12-21T03:15:03+00:00" + "time": "2018-12-21T07:43:51+00:00" }, { "name": "dipper/jwt-auth", diff --git a/database/migrations/2018_11_16_190020_create_failed_jobs_table.php b/database/migrations/2018_11_16_190020_create_failed_jobs_table.php index d432dff0..54e7d59f 100644 --- a/database/migrations/2018_11_16_190020_create_failed_jobs_table.php +++ b/database/migrations/2018_11_16_190020_create_failed_jobs_table.php @@ -20,6 +20,8 @@ class CreateFailedJobsTable extends Migration $table->longText('payload'); $table->longText('exception'); $table->timestamp('failed_at')->useCurrent(); + + $table->comment('失败任务表'); }); } diff --git a/database/migrations/2018_11_27_175137_create_base_tables.php b/database/migrations/2018_11_27_175137_create_base_tables.php index d85f061a..c3a1b68a 100644 --- a/database/migrations/2018_11_27_175137_create_base_tables.php +++ b/database/migrations/2018_11_27_175137_create_base_tables.php @@ -15,7 +15,7 @@ class CreateBaseTables extends Migration public function up() { foreach (app(Dicts::class)->get('tables') as $prefix => $type) { - Schema::create("{$prefix}_companies", function (Blueprint $table) { + Schema::create("{$prefix}_companies", function (Blueprint $table) use ($type) { $table->increments('id')->comment('企业ID'); $table->string('sn', 32)->comment('企业编号'); $table->string('name', 32)->default('')->comment('企业名称'); @@ -28,11 +28,10 @@ class CreateBaseTables extends Migration $table->softDeletes(); $table->unique(['sn', 'deleted_at']); + $table->comment("{$type}企业"); }); - db_alter("{$prefix}_companies", "{$type}企业"); - - Schema::create("{$prefix}_packages", function (Blueprint $table) { + Schema::create("{$prefix}_packages", function (Blueprint $table) use ($type) { $table->increments('id')->comment('企业ID'); $table->integer('parent_id')->unsigned()->default(0)->comment('父级ID'); $table->string('sn', 20)->comment('套餐编号'); @@ -61,11 +60,11 @@ class CreateBaseTables extends Migration $table->index('parent_id'); $table->index('type'); $table->index('carrier_operator'); + + $table->comment("{$type}套餐"); }); - db_alter("{$prefix}_packages", "{$type}套餐"); - - Schema::create("{$prefix}_order_cards", function (Blueprint $table) { + Schema::create("{$prefix}_order_cards", function (Blueprint $table) use ($type) { $table->increments('id')->comment('关联表ID'); $table->bigInteger('sim')->unsigned()->default(0)->comment('sim号'); $table->integer('order_id')->unsigned()->default(0)->comment('订单ID'); @@ -76,11 +75,11 @@ class CreateBaseTables extends Migration $table->unique(['sim', 'order_id']); $table->unique(['sim', 'deleted_at']); - }); - - db_alter("{$prefix}_cards", "{$type}订单企业套餐卡关联表"); - Schema::create("{$prefix}_added_orders", function (Blueprint $table) { + $table->comment("{$type}订单企业套餐卡关联表"); + }); + + Schema::create("{$prefix}_added_orders", function (Blueprint $table) use ($type) { $table->increments('id')->comment('订单ID'); $table->string('sn', 32)->comment('订单编号'); $table->tinyInteger('type')->unsigned()->default(0)->comment('订单类型(1:套餐续费 2:续费包 3:加油包 4:可选包 5:附加包)'); @@ -99,9 +98,9 @@ class CreateBaseTables extends Migration $table->index('type'); $table->index('company_id'); $table->index('order_at'); - }); - db_alter("{$prefix}_orders", "{$type}增值包订单"); + $table->comment("{$type}增值包订单"); + }); } Schema::create("real_orders", function (Blueprint $table) { @@ -127,9 +126,9 @@ class CreateBaseTables extends Migration $table->index('type'); $table->index('company_id'); $table->index('order_at'); - }); - db_alter("real_orders", "RD订单"); + $table->comment('RD订单'); + }); Schema::create("blocs", function (Blueprint $table) { $table->increments('id')->comment('集团ID'); @@ -143,9 +142,9 @@ class CreateBaseTables extends Migration $table->unique(['sn', 'deleted_at']); $table->index('name'); $table->index('carrier_operator'); - }); - db_alter("blocs", "卡源集团"); + $table->comment('卡源集团'); + }); Schema::create("cards", function (Blueprint $table) { $table->bigInteger('sim')->unsigned()->default(0)->comment('sim号'); @@ -159,10 +158,9 @@ class CreateBaseTables extends Migration $table->timestamps(); $table->primary('sim'); + $table->comment('卡基础信息表'); }); - db_alter("cards", "卡基础信息表"); - Schema::create("virtual_company_accounts", function (Blueprint $table) { $table->increments('id')->comment('自增ID'); $table->integer('company_id')->unsigned()->default(0)->comment('企业ID'); @@ -176,6 +174,7 @@ class CreateBaseTables extends Migration $table->softDeletes(); $table->unique(['mobile', 'deleted_at']); + $table->comment('VD企业账号表'); }); Schema::create("virtual_company_addresses", function (Blueprint $table) { @@ -189,6 +188,8 @@ class CreateBaseTables extends Migration $table->tinyInteger('status')->unsigned()->default(0)->comment('状态 0:正常 1:禁用'); $table->timestamps(); $table->softDeletes(); + + $table->comment('VD企业收货地址表'); }); Schema::create("virtual_products", function (Blueprint $table) { @@ -204,6 +205,8 @@ class CreateBaseTables extends Migration $table->softDeletes(); $table->unique(['sn', 'deleted_at']); + + $table->comment('VD企业定价表'); }); } diff --git a/database/migrations/2018_11_27_175146_create_order_tables.php b/database/migrations/2018_11_27_175146_create_order_tables.php index ecfe1751..ad2b889e 100644 --- a/database/migrations/2018_11_27_175146_create_order_tables.php +++ b/database/migrations/2018_11_27_175146_create_order_tables.php @@ -26,7 +26,7 @@ class CreateOrderTables extends Migration foreach ($this->tables as $table_name => $table_comment) { $table_name = $prefix . '_' . $table_name; $table_comment = $type . $table_comment; - Schema::create($table_name, function (Blueprint $table) use ($prefix) { + Schema::create($table_name, function (Blueprint $table) use ($prefix, $table_comment) { $table->integer('order_id')->unsigned()->default(0)->comment('订单ID'); $table->bigInteger('sim')->unsigned()->default(0)->comment('SIM卡号'); @@ -38,9 +38,8 @@ class CreateOrderTables extends Migration $table->integer('counts')->unsigned()->default(1)->comment('数量'); $table->integer('unit_price')->unsigned()->default(0)->comment('单价'); $table->primary(['order_id', 'sim']); + $table->comment($table_comment); }); - - db_alter($table_name, $table_comment); } } } diff --git a/database/migrations/2018_11_27_175152_create_package_tables.php b/database/migrations/2018_11_27_175152_create_package_tables.php index 1ec62eb5..0268247a 100644 --- a/database/migrations/2018_11_27_175152_create_package_tables.php +++ b/database/migrations/2018_11_27_175152_create_package_tables.php @@ -23,13 +23,12 @@ class CreatePackageTables extends Migration public function up() { foreach ($this->tables as $table_name => $table_comment) { - Schema::create($table_name, function (Blueprint $table) { + Schema::create($table_name, function (Blueprint $table) use ($table_comment) { $table->integer('package_id')->unsigned()->default(0)->comment('套餐ID'); $table->bigInteger('sim')->unsigned()->default(0)->comment('SIM卡号'); $table->primary(['package_id', 'sim']); + $table->comment($table_comment); }); - - db_alter($table_name, $table_comment); } } diff --git a/database/migrations/2018_12_12_170419_create_virtual_orders_table.php b/database/migrations/2018_12_12_170419_create_virtual_orders_table.php index 24b1421a..44ef15d5 100644 --- a/database/migrations/2018_12_12_170419_create_virtual_orders_table.php +++ b/database/migrations/2018_12_12_170419_create_virtual_orders_table.php @@ -45,9 +45,8 @@ class CreateVirtualOrdersTable extends Migration $table->index('type'); $table->index('company_id'); $table->index('order_at'); + $table->comment('VD订单'); }); - - db_alter("virtual_orders", "VD订单"); } /** diff --git a/database/migrations/2018_12_21_134548_create_tests_table.php b/database/migrations/2018_12_21_134548_create_tests_table.php new file mode 100644 index 00000000..27edb0f2 --- /dev/null +++ b/database/migrations/2018_12_21_134548_create_tests_table.php @@ -0,0 +1,37 @@ +increments('id'); + $table->string('sn', 32)->default('')->comment('编号'); + $table->softDeletes(); + + $table->unique(['sn', 'deleted_at']); + + $table->comment('测试'); + $table->setIncrement(100); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('tests'); + } +} diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php index dfb85605..b8726a02 100644 --- a/vendor/composer/autoload_classmap.php +++ b/vendor/composer/autoload_classmap.php @@ -14,6 +14,7 @@ return array( 'CreateFailedJobsTable' => $baseDir . '/database/migrations/2018_11_16_190020_create_failed_jobs_table.php', 'CreateOrderTables' => $baseDir . '/database/migrations/2018_11_27_175146_create_order_tables.php', 'CreatePackageTables' => $baseDir . '/database/migrations/2018_11_27_175152_create_package_tables.php', + 'CreateTestsTable' => $baseDir . '/database/migrations/2018_12_21_134548_create_tests_table.php', 'CreateVirtualOrdersTable' => $baseDir . '/database/migrations/2018_12_12_170419_create_virtual_orders_table.php', 'DatabaseSeeder' => $baseDir . '/database/seeds/DatabaseSeeder.php', 'DivisionByZeroError' => $vendorDir . '/symfony/polyfill-php70/Resources/stubs/DivisionByZeroError.php', diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index cf40a125..aa04e54b 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -717,6 +717,7 @@ class ComposerStaticInite79258a3e34ad3e251999111d9f334d9 'CreateFailedJobsTable' => __DIR__ . '/../..' . '/database/migrations/2018_11_16_190020_create_failed_jobs_table.php', 'CreateOrderTables' => __DIR__ . '/../..' . '/database/migrations/2018_11_27_175146_create_order_tables.php', 'CreatePackageTables' => __DIR__ . '/../..' . '/database/migrations/2018_11_27_175152_create_package_tables.php', + 'CreateTestsTable' => __DIR__ . '/../..' . '/database/migrations/2018_12_21_134548_create_tests_table.php', 'CreateVirtualOrdersTable' => __DIR__ . '/../..' . '/database/migrations/2018_12_12_170419_create_virtual_orders_table.php', 'DatabaseSeeder' => __DIR__ . '/../..' . '/database/seeds/DatabaseSeeder.php', 'DivisionByZeroError' => __DIR__ . '/..' . '/symfony/polyfill-php70/Resources/stubs/DivisionByZeroError.php', diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index af15c84c..a49d3cd9 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -641,18 +641,18 @@ }, { "name": "dipper/foundation", - "version": "1.1.8", - "version_normalized": "1.1.8.0", + "version": "1.1.9", + "version_normalized": "1.1.9.0", "source": { "type": "git", "url": "ssh://gogs@git.fxft.net:2222/composer/foundation.git", - "reference": "0010bd177e6a367285a6ff3401f265bc80ef32fb" + "reference": "94efaf5b1e21d1bc4f7bae4fc6c4d3f741b399d0" }, "dist": { "type": "tar", - "url": "https://composer.fxft.online/dist/dipper/foundation/dipper-foundation-1.1.8-30793d.tar", - "reference": "0010bd177e6a367285a6ff3401f265bc80ef32fb", - "shasum": "6839ae4c43c3f38f4fe2ca22a1cc06b75934debd" + "url": "https://composer.fxft.online/dist/dipper/foundation/dipper-foundation-1.1.9-51f1b8.tar", + "reference": "94efaf5b1e21d1bc4f7bae4fc6c4d3f741b399d0", + "shasum": "b17959dd9990df31f7e6c3cff53749afe151f670" }, "require": { "barryvdh/laravel-cors": "~0.11", @@ -667,7 +667,7 @@ "league/flysystem": "~1.0", "nesbot/carbon": "~1.21" }, - "time": "2018-12-21T03:15:03+00:00", + "time": "2018-12-21T07:43:51+00:00", "type": "library", "installation-source": "dist", "autoload": { diff --git a/vendor/dipper/foundation/src/Database/DatabaseServiceProvider.php b/vendor/dipper/foundation/src/Database/DatabaseServiceProvider.php index 494c90bc..048150b5 100644 --- a/vendor/dipper/foundation/src/Database/DatabaseServiceProvider.php +++ b/vendor/dipper/foundation/src/Database/DatabaseServiceProvider.php @@ -44,6 +44,8 @@ class DatabaseServiceProvider extends ServiceProvider QueryBuilder::macro('createOrIgnore', $this->macroCreateOrIgnore()); QueryBuilder::macro('createNotExist', $this->macroCreateNotExist()); QueryBuilder::macro('updateBatch', $this->macroUpdateBatch()); + SchemaBlueprint::macro('comment', $this->macroSchemaComment()); + SchemaBlueprint::macro('setIncrement', $this->macroSchemaSetIncrement()); } /** @@ -223,4 +225,28 @@ class DatabaseServiceProvider extends ServiceProvider ); }; } + + /** + * 表备注 + * + * @return void + */ + public function macroSchemaComment() + { + return function ($comment) { + return $this->addCommand('comment', compact('comment')); + }; + } + + /** + * 自增开始 + * + * @return void + */ + public function macroSchemaSetIncrement() + { + return function ($number) { + return $this->addCommand('setIncrement', compact('number')); + }; + } } diff --git a/vendor/dipper/foundation/src/Database/MysqlSchemaGrammar.php b/vendor/dipper/foundation/src/Database/MysqlSchemaGrammar.php index 08542032..ae4a1dac 100644 --- a/vendor/dipper/foundation/src/Database/MysqlSchemaGrammar.php +++ b/vendor/dipper/foundation/src/Database/MysqlSchemaGrammar.php @@ -10,5 +10,35 @@ use Illuminate\Database\Schema\Grammars\MySqlGrammar as Grammar; class MysqlSchemaGrammar extends Grammar { + /** + * Compile a unique key command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @return string + */ + public function compileComment(Blueprint $blueprint, Fluent $command) + { + return sprintf( + "alter table %s comment '%s'", + $this->wrapTable($blueprint), + $command->comment + ); + } + /** + * Compile a unique key command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @return string + */ + public function compileSetIncrement(Blueprint $blueprint, Fluent $command) + { + return sprintf( + "alter table %s auto_increment %s", + $this->wrapTable($blueprint), + $command->number + ); + } } diff --git a/vendor/dipper/foundation/src/Database/PostgresSchemaGrammar.php b/vendor/dipper/foundation/src/Database/PostgresSchemaGrammar.php index 4eea35be..eca279a5 100644 --- a/vendor/dipper/foundation/src/Database/PostgresSchemaGrammar.php +++ b/vendor/dipper/foundation/src/Database/PostgresSchemaGrammar.php @@ -10,6 +10,38 @@ use Illuminate\Database\Schema\Grammars\PostgresGrammar as Grammar; class PostgresSchemaGrammar extends Grammar { + /** + * Compile a create table command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @return string + */ + public function compileCreate(Blueprint $blueprint, Fluent $command) + { + $sql = []; + + $sql[] = sprintf( + '%s table %s (%s)', + $blueprint->temporary ? 'create temporary' : 'create', + $this->wrapTable($blueprint), + implode(', ', $this->getColumns($blueprint)) + ); + + $comments = collect($blueprint->getAddedColumns())->where('comment', '<>', '')->all(); + + foreach ($comments as $comment) { + $sql[] = sprintf( + "comment on column %s.%s is '%s'", + $this->wrapTable($blueprint), + $comment->name, + $comment->comment + ); + } + + return $sql; + } + /** * Compile a unique key command. * @@ -27,6 +59,39 @@ class PostgresSchemaGrammar extends Grammar ); } + /** + * Compile a unique key command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @return string + */ + public function compileComment(Blueprint $blueprint, Fluent $command) + { + return sprintf( + "comment on table %s is '%s'", + $this->wrapTable($blueprint), + $command->comment + ); + } + + /** + * Compile a unique key command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @return string + */ + public function compileSetIncrement(Blueprint $blueprint, Fluent $command) + { + $column = collect($blueprint->getColumns())->where('autoIncrement', true)->first(); + + if ($column) { + $index = $this->wrap("{$blueprint->getTable()}_{$column->name}_seq"); + return sprintf("select setval('%s', %d, true);", $index, $command->number); + } + } + /** * Convert an array of column names into a delimited string. *