
โ RLS๋ฅผ Drizzle๋ก ์์ฑํ๋ฉด ์๊ธฐ๋ ์ด์
1. ํ์ ์คํฌ๋ฆฝํธ ์๋ ์์ฑ ๊ธฐ๋ฅ์ ์ฌ์ฉํ ์ ์๋ค.
2. ์์ฑํ ๊ท์น๋ค์ด SQL migration ํ์ผ์ ๋ค์ด๊ฐ๊ธฐ ๋๋ฌธ์, git์ผ๋ก ๋ฒ์ ๊ด๋ฆฌ๋ฅผ ํ ์ ์๋ค.
3. Drizzle์๋ ํน๋ณํ Supabase์ ํจ๊ป RLS๋ฅผ ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ์ด ๋ฐ๋ก ๋ง๋ จ๋์ด ์๋ค. (์ข์ ์ ํธ๋ฆฌํฐ ํจ์๋ค์ด ์์ด์ ์๊ฐ์ ์ ์ฝํ ์ ์๋ค.)
https://orm.drizzle.team/docs/rls#using-with-supabase
Drizzle ORM - Row-Level Security (RLS)
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
orm.drizzle.team
โ Usage
export const todos = pgTable(
"todos",
{
todo_id: bigint({ mode: "number" })
.primaryKey()
.generatedAlwaysAsIdentity(),
title: text().notNull(),
completed: boolean().notNull().default(false),
created_at: timestamp().notNull().defaultNow(),
profile_id: uuid()
.references(() => profiles.profile_id, {
onDelete: "cascade",
})
.notNull(),
},
(table) => [
pgPolicy("todos-select-policy", {
for: "select",
to: authenticatedRole,
as: "permissive",
using: sql`${authUid} = ${table.profile_id}`,
}),
pgPolicy("todos-insert-policy", {
for: "insert",
to: authenticatedRole,
as: "permissive",
withCheck: sql`${authUid} = ${table.profile_id}`,
}),
],
);'๐งฉ SQL' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
| SQL - Supabase PostgreSQL - Cron Job (0) | 2026.07.16 |
|---|---|
| SQL - PostgreSQL - Security Definer View (0) | 2026.07.15 |
| SQL - PostgreSQL - RLS(Row Level Security) (0) | 2026.07.15 |
| SQL - PostgreSQL - CREATE OR REPLACE๊ฐ ๊ฐ๋ฅํ ๋์ ๋ถ๊ฐ๋ฅํ ๋ (0) | 2026.07.13 |
| SQL - PostgreSQL - SET search_path = ''๋ฅผ ์ฌ์ฉํ๋ ์ด์ ? (0) | 2026.07.13 |