快捷创建分区表

This commit is contained in:
邓皓元 2019-01-29 18:14:12 +08:00
parent 657bcd83da
commit 6af8f0cf46
3 changed files with 46 additions and 14 deletions

View File

@ -28,16 +28,34 @@ class CreateRealAddedOrderCardsTables extends Migration
$table->integer('counts')->unsigned()->default(0)->comment('数量');
$table->timestamps();
$table->unique(['sim', 'order_id']);
$table->comment("RD续费及增值包订单关联卡");
$table->partition('type', 'list');
$table->addPartition('real_added_order_renewal_cards', 'list', 1);
$table->addPartition('real_added_order_renewal_package_cards', 'list', 2);
$table->addPartition('real_added_order_flows_package_cards', 'list', 3);
$table->addPartition('real_added_order_optional_package_cards', 'list', 4);
$table->addPartition('real_added_order_additional_package_cards', 'list', 5);
$table->addPartition('real_added_order_renewal_cards', 'list', [1]);
$table->addPartition('real_added_order_renewal_package_cards', 'list', [2]);
$table->addPartition('real_added_order_flows_package_cards', 'list', [3]);
$table->addPartition('real_added_order_optional_package_cards', 'list', [4]);
$table->addPartition('real_added_order_additional_package_cards', 'list', [5]);
});
Schema::table('real_added_order_renewal_cards', function (Blueprint $table) {
$table->unique(['sim', 'order_id']);
});
Schema::table('real_added_order_renewal_package_cards', function (Blueprint $table) {
$table->unique(['sim', 'order_id']);
});
Schema::table('real_added_order_flows_package_cards', function (Blueprint $table) {
$table->unique(['sim', 'order_id']);
});
Schema::table('real_added_order_optional_package_cards', function (Blueprint $table) {
$table->unique(['sim', 'order_id']);
});
Schema::table('real_added_order_additional_package_cards', function (Blueprint $table) {
$table->unique(['sim', 'order_id']);
});
// DB::unprepared(File::get(__DIR__ . '/create_real_added_order_cards_table.pgsql'));

View File

@ -33,16 +33,30 @@ class CreateVirtualOrderCardsTables extends Migration
$table->timestamps();
$table->softDeletes();
$table->unique(['sim', 'order_id', 'deleted_at']);
$table->comment("VD卡关联套餐订单");
$table->partition('type', 'list');
$table->addPartition('virtual_order_cards', 'list', 0);
$table->addPartition('virtual_order_renewal_cards', 'list', 1);
$table->addPartition('virtual_order_renewal_package_cards', 'list', 2);
$table->addPartition('virtual_order_flows_package_cards', 'list', 3);
$table->addPartition('virtual_order_cards', 'list', [0]);
$table->addPartition('virtual_order_renewal_cards', 'list', [1]);
$table->addPartition('virtual_order_renewal_package_cards', 'list', [2]);
$table->addPartition('virtual_order_flows_package_cards', 'list', [3]);
});
Schema::table('virtual_order_cards', function (Blueprint $table) {
$table->unique(['sim', 'order_id', 'deleted_at']);
});
Schema::table('virtual_order_renewal_cards', function (Blueprint $table) {
$table->unique(['sim', 'order_id', 'deleted_at']);
});
Schema::table('virtual_order_renewal_package_cards', function (Blueprint $table) {
$table->unique(['sim', 'order_id', 'deleted_at']);
});
Schema::table('virtual_order_flows_package_cards', function (Blueprint $table) {
$table->unique(['sim', 'order_id', 'deleted_at']);
});
}

View File

@ -55,7 +55,7 @@ class CreateFlowPoolTables extends Migration
}
if (!Schema::hasTable('virtual_flow_pool_settings')) {
Schema::create('virtual_flow_pools', function (Blueprint $table) {
Schema::create('virtual_flow_pool_settings', function (Blueprint $table) {
$table->increments('id')->comment('自增ID');
$table->integer('pool_id')->unsigned()->default(0)->comment('流量池ID');
$table->text('minimum_settings')->nullable()->comment('套餐保底配置');