Skip to content

Commit 7e68218

Browse files
committed
Merge branch 'alternation-engine' of github.com:drizzle-team/drizzle-orm into alternation-engine
2 parents 93849ec + 61e758f commit 7e68218

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

drizzle-kit/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Drizzle Kit is a CLI migrator tool for Drizzle ORM. It is probably the one and o
77

88
Check the full documentation on [the website](https://orm.drizzle.team/kit-docs/overview).
99

10+
1011
### How it works
1112

1213
Drizzle Kit traverses a schema module and generates a snapshot to compare with the previous version, if there is one.

drizzle-kit/tests/postgres/pull.test.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
pgPolicy,
2525
pgRole,
2626
pgSchema,
27+
pgSequence,
2728
pgTable,
2829
pgView,
2930
real,
@@ -33,6 +34,7 @@ import {
3334
text,
3435
time,
3536
timestamp,
37+
unique,
3638
uuid,
3739
varchar,
3840
} from 'drizzle-orm/pg-core';
@@ -1072,6 +1074,48 @@ test('introspect partitioned tables', async () => {
10721074
]);
10731075
});
10741076

1077+
test('default sequence nextval', async () => {
1078+
const seqOrgCode = pgSequence('seq_org_code', {
1079+
startWith: '1000',
1080+
increment: '1',
1081+
minValue: '1',
1082+
maxValue: '9223372036854775807',
1083+
cache: '1',
1084+
cycle: false,
1085+
});
1086+
1087+
const organizations = pgTable('organizations', {
1088+
code: bigint({ mode: 'number' }).default(sql`nextval('seq_org_code'::regclass)`).notNull(),
1089+
});
1090+
1091+
const { sqlStatements } = await diffIntrospect(db, { seqOrgCode, organizations }, 'default_sequence_nextval');
1092+
1093+
expect(sqlStatements).toStrictEqual([]);
1094+
});
1095+
1096+
test('policy', async () => {
1097+
const organizationsInCore = pgTable('organizations', {
1098+
domain: text(),
1099+
}, (table) => [
1100+
unique('organizations_domain_key').on(table.domain),
1101+
]);
1102+
1103+
const policy = pgPolicy('new_policy', {
1104+
as: 'restrictive',
1105+
to: 'postgres',
1106+
withCheck: sql`1 = 1`,
1107+
for: 'all',
1108+
}).link(organizationsInCore);
1109+
1110+
const { sqlStatements } = await diffIntrospect(
1111+
db,
1112+
{ organizationsInCore, policy },
1113+
'policy',
1114+
);
1115+
1116+
expect(sqlStatements).toStrictEqual([]);
1117+
});
1118+
10751119
// test('introspect foreign tables', async () => {
10761120
// await db.query('CREATE EXTENSION postgres_fdw;');
10771121
// await db.query("CREATE SERVER film_server FOREIGN DATA WRAPPER postgres_fdw OPTIONS (host 'foo', dbname 'foodb', port '5432');");

0 commit comments

Comments
 (0)