要创建加密表,可以使用以下查询:
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中实现。
谢谢
答案 0 :(得分:0)
尝试一下:
//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不被视为afaik。