@xata.io/drizzle 0.0.0-alpha.ve2d648b → 0.0.0-alpha.ve304656137a7c41a3f10b52dcfd4784695e12cb2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +16 -5
- package/CHANGELOG.md +133 -2
- package/README.md +3 -0
- package/dist/index.cjs +98 -123
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +47 -65
- package/dist/index.mjs +96 -123
- package/dist/index.mjs.map +1 -1
- package/dist/pg.cjs +215 -0
- package/dist/pg.cjs.map +1 -0
- package/dist/pg.d.ts +61 -0
- package/dist/pg.mjs +209 -0
- package/dist/pg.mjs.map +1 -0
- package/package.json +12 -4
- package/test/core.schema.ts +93 -0
- package/test/core.test.ts +3768 -0
- package/test/drizzle.test.ts +6293 -0
- package/test/migrate/0000_puzzling_flatman.sql +37 -0
- package/test/migrate/0001_test.sql +5 -0
- package/test/migrate/meta/0000_snapshot.json +275 -0
- package/test/migrate/meta/_journal.json +20 -0
- package/test/relational.schema.ts +85 -0
- package/test/relational.test.ts +6294 -0
- package/test/schema.ts +85 -0
@@ -0,0 +1,93 @@
|
|
1
|
+
import {
|
2
|
+
boolean,
|
3
|
+
char,
|
4
|
+
cidr,
|
5
|
+
inet,
|
6
|
+
integer,
|
7
|
+
jsonb,
|
8
|
+
macaddr,
|
9
|
+
macaddr8,
|
10
|
+
pgTable,
|
11
|
+
serial,
|
12
|
+
text,
|
13
|
+
timestamp
|
14
|
+
} from 'drizzle-orm/pg-core';
|
15
|
+
|
16
|
+
export const usersTable = pgTable('users', {
|
17
|
+
id: serial('id' as string).primaryKey(),
|
18
|
+
name: text('name').notNull(),
|
19
|
+
verified: boolean('verified').notNull().default(false),
|
20
|
+
jsonb: jsonb('jsonb').$type<string[]>(),
|
21
|
+
createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow()
|
22
|
+
});
|
23
|
+
|
24
|
+
export const citiesTable = pgTable('cities', {
|
25
|
+
id: serial('id').primaryKey(),
|
26
|
+
name: text('name').notNull(),
|
27
|
+
state: char('state', { length: 2 })
|
28
|
+
});
|
29
|
+
|
30
|
+
export const cities2Table = pgTable('cities', {
|
31
|
+
id: serial('id').primaryKey(),
|
32
|
+
name: text('name').notNull()
|
33
|
+
});
|
34
|
+
|
35
|
+
export const users2Table = pgTable('users2', {
|
36
|
+
id: serial('id').primaryKey(),
|
37
|
+
name: text('name').notNull(),
|
38
|
+
cityId: integer('city_id').references(() => citiesTable.id)
|
39
|
+
});
|
40
|
+
|
41
|
+
export const coursesTable = pgTable('courses', {
|
42
|
+
id: serial('id').primaryKey(),
|
43
|
+
name: text('name').notNull(),
|
44
|
+
categoryId: integer('category_id').references(() => courseCategoriesTable.id)
|
45
|
+
});
|
46
|
+
|
47
|
+
export const courseCategoriesTable = pgTable('course_categories', {
|
48
|
+
id: serial('id').primaryKey(),
|
49
|
+
name: text('name').notNull()
|
50
|
+
});
|
51
|
+
|
52
|
+
export const orders = pgTable('orders', {
|
53
|
+
id: serial('id').primaryKey(),
|
54
|
+
region: text('region').notNull(),
|
55
|
+
product: text('product')
|
56
|
+
.notNull()
|
57
|
+
.$default(() => 'random_string'),
|
58
|
+
amount: integer('amount').notNull(),
|
59
|
+
quantity: integer('quantity').notNull()
|
60
|
+
});
|
61
|
+
|
62
|
+
export const network = pgTable('network_table', {
|
63
|
+
inet: inet('inet').notNull(),
|
64
|
+
cidr: cidr('cidr').notNull(),
|
65
|
+
macaddr: macaddr('macaddr').notNull(),
|
66
|
+
macaddr8: macaddr8('macaddr8').notNull()
|
67
|
+
});
|
68
|
+
|
69
|
+
export const salEmp = pgTable('sal_emp', {
|
70
|
+
name: text('name'),
|
71
|
+
payByQuarter: integer('pay_by_quarter').array(),
|
72
|
+
schedule: text('schedule').array().array()
|
73
|
+
});
|
74
|
+
|
75
|
+
export const _tictactoe = pgTable('tictactoe', {
|
76
|
+
squares: integer('squares').array(3).array(3)
|
77
|
+
});
|
78
|
+
|
79
|
+
export const usersMigratorTable = pgTable('users12', {
|
80
|
+
id: serial('id').primaryKey(),
|
81
|
+
name: text('name').notNull(),
|
82
|
+
email: text('email').notNull()
|
83
|
+
});
|
84
|
+
|
85
|
+
// To test aggregate functions
|
86
|
+
export const aggregateTable = pgTable('aggregate_table', {
|
87
|
+
id: serial('id').notNull(),
|
88
|
+
name: text('name').notNull(),
|
89
|
+
a: integer('a'),
|
90
|
+
b: integer('b'),
|
91
|
+
c: integer('c'),
|
92
|
+
nullOnly: integer('null_only')
|
93
|
+
});
|