ํจ์ ์ด๋ฆ์ ํ ์ด๋ธ ์ด ๊ธฐ๋ณธ๊ฐ์ผ๋ก ์ง์ ํ๋ฉด ๋ฐ์ดํ๋ก ๋ฌถ์ด๋ฏ๋ก ์คํ๋ ๋ ํจ์๊ฐ ์คํ๋์ง ์๊ณ ๋ฌธ์์ด๋ก ์ ์ฅ๋ฉ๋๋ค.
๋คํ์ค๋ฝ๊ฒ๋ UUID col์ ์ด ์ ํ์ ๊ธฐ๋ณธ ๋ฌธ์์ด ๊ฐ์ ๊ฐ์ง ์ ์๊ธฐ ๋๋ฌธ์ ์ค๋ฅ๊ฐ ๋ฐ์ํฉ๋๋ค.
Schema::create('products', function(Blueprint $table)
{
$table->uuid('id')->default('gen_random_uuid()')->primary('products_pkey');
$table->string('name')->nullable();
$table->string('max_projects')->nullable();
$table->timestamps();
$table->softDeletes();
});
DB::raw
์๋:
$table->uuid('id')->default(DB::raw('gen_random_uuid()'))->primary('products_pkey');
MySQL์์๋ ํจ์๋ฅผ ๊ธฐ๋ณธ๊ฐ์ผ๋ก ์ฌ์ฉํ ์ ์์ต๋๋ค. ์ผ์ ํด์ผ ํฉ๋๋ค. UUID๋ฅผ ์์ฑํ๋ ค๋ฉด ํธ๋ฆฌ๊ฑฐ๋ฅผ ์ฌ์ฉํ๊ฑฐ๋ ์๋์ผ๋ก ์ํํด์ผ ํฉ๋๋ค.
gen_random_uuid()
๋ Postgre ํจ์์
๋๋ค.
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
DB::raw
์๋: