To create an encrypted table the following query can be used:
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'
How can this be implemented in Laravel.
Thank you
Try this:
//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'");
}
Side note, BIGINT value can have maximum constraint of 20 so 32 wouldn't be considered afaik.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.