How to implement partition in laravel database migration

前端 未结 2 828
轻奢々
轻奢々 2021-01-07 09:32

Using Laravel 5.3 how can I implement partition. Following is the mysql table structure I\'m trying to add in migration.

CREATE TABLE `settings` (
    `id` I         


        
2条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-07 09:39

    I think it is help to you,

          Schema::create('settings', function(Blueprint $table) {
             $table-> increments('id');
             $table->integer('client_id')->primary();
             $table->string('key');
             $table->text('value');
             $table->timestamps();
    
             $table->unique(['client_id', 'key']);
           });         
    

    or

          Schema::create('settings', function(Blueprint $table) {
             $table-> increments('id');
             $table->integer('client_id');
             $table->string('key');
             $table->text('value');
             $table->timestamps();
    
             $table->primary('client_id');
             $table->unique(['client_id', 'key']);
           });         
    

    I searched everywhere, i can't solution find for partition.
    But,

    My suggestion use, below unprepared into the migration file functions of up and down function

    DB::unprepared()   
    

    in migration to run your SQL query with partition.

    like,

    DB::unprepared('create table....')
    

提交回复
热议问题