使用keyring和laravel

jhkqcmku  于 2021-06-23  发布在  Mysql
关注(0)|答案(1)|浏览(303)

要创建加密表,可以使用以下查询:

CREATE TABLE `t1` (
  `intcol1` int(32) DEFAULT NULL,
  `intcol2` int(32) DEFAULT NULL,
  `charcol1` varchar(128) DEFAULT NULL,
  `charcol2` varchar(128) DEFAULT NULL,
  `charcol3` varchar(128) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ENCRYPTION='Y'

如何在laravel中实现这一点。
谢谢您

6ss1mwsb

6ss1mwsb1#

试试这个:

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

public function up()
{
    Schema::create('t1', function (Blueprint $table) {
        $table->bigInteger('intcol1')->nullable();
        $table->bigInteger('intco21')->nullable();
        $table->string('charcol1', 128)->nullable();
        $table->string('charcol2', 128)->nullable();
        $table->string('charcol3', 128)->nullable();
        $table->engine = 'InnoDB';
        $table->charset = 'latin1';
    });

    DB::statement("ALTER TABLE t1 ENCRYPTION='Y'");
}

请注意,bigint值的最大约束为20,因此32不会被认为是一个faik。

相关问题