pg-policy.test.ts — drizzle-orm Source File
Architecture documentation for pg-policy.test.ts, a typescript file in the drizzle-orm codebase. 4 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 120aac94_4106_dbd3_10ef_d230eef26fd6["pg-policy.test.ts"] 690f7dfc_0aea_9ee8_d6e7_26bbb3689031["drizzle-orm"] 120aac94_4106_dbd3_10ef_d230eef26fd6 --> 690f7dfc_0aea_9ee8_d6e7_26bbb3689031 53497908_16e7_977d_e97d_7414884a88a6["pg-core"] 120aac94_4106_dbd3_10ef_d230eef26fd6 --> 53497908_16e7_977d_e97d_7414884a88a6 2080849e_169d_739e_1ba9_1396fc229951["schemaDiffer"] 120aac94_4106_dbd3_10ef_d230eef26fd6 --> 2080849e_169d_739e_1ba9_1396fc229951 8d35eaf2_a542_cfd4_fa1a_fafca0f02686["vitest"] 120aac94_4106_dbd3_10ef_d230eef26fd6 --> 8d35eaf2_a542_cfd4_fa1a_fafca0f02686 style 120aac94_4106_dbd3_10ef_d230eef26fd6 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { sql } from 'drizzle-orm';
import { integer, pgPolicy, pgRole, pgSchema, pgTable } from 'drizzle-orm/pg-core';
import { diffTestSchemas } from 'tests/schemaDiffer';
import { expect, test } from 'vitest';
test('add policy + enable rls', async (t) => {
const schema1 = {
users: pgTable('users', {
id: integer('id').primaryKey(),
}),
};
const schema2 = {
users: pgTable('users', {
id: integer('id').primaryKey(),
}, () => ({
rls: pgPolicy('test', { as: 'permissive' }),
})),
};
const { statements, sqlStatements } = await diffTestSchemas(schema1, schema2, []);
expect(sqlStatements).toStrictEqual([
'ALTER TABLE "users" ENABLE ROW LEVEL SECURITY;',
'CREATE POLICY "test" ON "users" AS PERMISSIVE FOR ALL TO public;',
]);
expect(statements).toStrictEqual([
{
schema: '',
tableName: 'users',
type: 'enable_rls',
},
{
data: {
as: 'PERMISSIVE',
for: 'ALL',
name: 'test',
to: ['public'],
on: undefined,
using: undefined,
withCheck: undefined,
},
schema: '',
tableName: 'users',
type: 'create_policy',
},
]);
});
test('drop policy + disable rls', async (t) => {
const schema1 = {
users: pgTable('users', {
id: integer('id').primaryKey(),
}, () => ({
rls: pgPolicy('test', { as: 'permissive' }),
})),
};
const schema2 = {
users: pgTable('users', {
// ... (1597 more lines)
Dependencies
- drizzle-orm
- pg-core
- schemaDiffer
- vitest
Source
Frequently Asked Questions
What does pg-policy.test.ts do?
pg-policy.test.ts is a source file in the drizzle-orm codebase, written in typescript.
What does pg-policy.test.ts depend on?
pg-policy.test.ts imports 4 module(s): drizzle-orm, pg-core, schemaDiffer, vitest.
Where is pg-policy.test.ts in the architecture?
pg-policy.test.ts is located at drizzle-kit/tests/rls/pg-policy.test.ts (directory: drizzle-kit/tests/rls).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free