Skip to content

Commit 4a4629c

Browse files
Merge branch 'beta' into issue-3703
2 parents fc2c675 + 629b5aa commit 4a4629c

File tree

30 files changed

+1798
-132
lines changed

30 files changed

+1798
-132
lines changed

.gitignore

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,4 @@ dist-dts
1212
rollup.config-*.mjs
1313
*.log
1414
.DS_Store
15-
drizzle-seed/src/test.ts
16-
drizzle-seed/src/testMysql.ts
17-
drizzle-seed/src/testSqlite.ts
18-
drizzle-seed/src/schemaTest.ts
15+
drizzle-seed/src/dev

changelogs/drizzle-kit/0.30.2.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Fix certificates generation utility for Drizzle Studio; [[BUG]: [drizzle-kit]: drizzle-kit dependency on drizzle-studio perms error](https://github.com/drizzle-team/drizzle-orm/issues/3729)

changelogs/drizzle-orm/0.29.5.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ await migrate(db, {
6767
});
6868
```
6969

70-
### 🎉 SQLite Proxy bacth and Relational Queries support
70+
### 🎉 SQLite Proxy batch and Relational Queries support
7171

7272
- You can now use `.query.findFirst` and `.query.findMany` syntax with sqlite proxy driver
7373

changelogs/drizzle-seed/0.3.0.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# New features
2+
3+
## Drizzle Relations support
4+
5+
The `seed` function can now accept Drizzle Relations objects and treat them as foreign key constraints
6+
7+
8+
```ts
9+
// schema.ts
10+
import { integer, serial, text, pgTable } from 'drizzle-orm/pg-core';
11+
import { relations } from 'drizzle-orm';
12+
export const users = pgTable('users', {
13+
id: serial('id').primaryKey(),
14+
name: text('name').notNull(),
15+
});
16+
export const usersRelations = relations(users, ({ many }) => ({
17+
posts: many(posts),
18+
}));
19+
export const posts = pgTable('posts', {
20+
id: serial('id').primaryKey(),
21+
content: text('content').notNull(),
22+
authorId: integer('author_id').notNull(),
23+
});
24+
export const postsRelations = relations(posts, ({ one }) => ({
25+
author: one(users, { fields: [posts.authorId], references: [users.id] }),
26+
}));
27+
```
28+
29+
```ts
30+
// index.ts
31+
import { seed } from "drizzle-seed";
32+
import * as schema from './schema.ts'
33+
34+
async function main() {
35+
const db = drizzle(process.env.DATABASE_URL!);
36+
await seed(db, schema);
37+
}
38+
39+
main();
40+
```

drizzle-kit/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "drizzle-kit",
3-
"version": "0.30.1",
3+
"version": "0.30.2",
44
"homepage": "https://orm.drizzle.team",
55
"keywords": [
66
"drizzle",

drizzle-kit/src/introspect-singlestore.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ const singlestoreImportsList = new Set([
4949
'tinyint',
5050
'varbinary',
5151
'varchar',
52+
'vector',
5253
'year',
5354
'enum',
5455
]);
@@ -789,6 +790,16 @@ const column = (
789790
return out;
790791
}
791792

793+
if (lowered.startsWith('vector')) {
794+
const [dimensions, elementType] = lowered.substring('vector'.length + 1, lowered.length - 1).split(',');
795+
let out = `${casing(name)}: vector(${
796+
dbColumnName({ name, casing: rawCasing, withMode: true })
797+
}{ dimensions: ${dimensions}, elementType: ${elementType} })`;
798+
799+
out += defaultValue ? `.default(${mapColumnDefault(defaultValue, isExpression)})` : '';
800+
return out;
801+
}
802+
792803
console.log('uknown', type);
793804
return `// Warning: Can't parse ${type} from database\n\t// ${type}Type: ${type}("${name}")`;
794805
};

drizzle-kit/src/serializer/singlestoreSerializer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export const generateSingleStoreSnapshot = (
130130
if (typeof column.default === 'string') {
131131
columnToSet.default = `'${column.default}'`;
132132
} else {
133-
if (sqlTypeLowered === 'json') {
133+
if (sqlTypeLowered === 'json' || Array.isArray(column.default)) {
134134
columnToSet.default = `'${JSON.stringify(column.default)}'`;
135135
} else if (column.default instanceof Date) {
136136
if (sqlTypeLowered === 'date') {

drizzle-kit/src/utils/certs.ts

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,29 @@ import { access, readFile } from 'fs/promises';
44
import { join } from 'path';
55
import { $ } from 'zx';
66

7-
const p = envPaths('drizzle-studio', {
8-
suffix: '',
9-
});
10-
11-
$.verbose = false;
12-
$.cwd = p.data;
13-
mkdirSync(p.data, { recursive: true });
14-
157
export const certs = async () => {
16-
const res = await $`mkcert --help`.nothrow();
8+
$.verbose = false;
179

18-
// ~/.local/share/drizzle-studio
19-
const keyPath = join(p.data, 'localhost-key.pem');
20-
const certPath = join(p.data, 'localhost.pem');
10+
const res = await $`mkcert --help`.nothrow();
2111

2212
if (res.exitCode === 0) {
13+
const p = envPaths('drizzle-studio', {
14+
suffix: '',
15+
});
16+
17+
$.cwd = p.data;
18+
19+
// create ~/.local/share/drizzle-studio
20+
mkdirSync(p.data, { recursive: true });
21+
22+
const keyPath = join(p.data, 'localhost-key.pem');
23+
const certPath = join(p.data, 'localhost.pem');
24+
2325
try {
26+
// check if the files exist
2427
await Promise.all([access(keyPath), access(certPath)]);
2528
} catch (e) {
29+
// if not create them
2630
await $`mkcert localhost`.nothrow();
2731
}
2832
const [key, cert] = await Promise.all([
@@ -33,5 +37,3 @@ export const certs = async () => {
3337
}
3438
return null;
3539
};
36-
37-
certs();

drizzle-kit/tests/push/singlestore.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
tinyint,
2424
varbinary,
2525
varchar,
26+
vector,
2627
year,
2728
} from 'drizzle-orm/singlestore-core';
2829
import getPort from 'get-port';
@@ -249,6 +250,13 @@ const singlestoreSuite: DialectSuite = {
249250
columnNotNull: binary('column_not_null', { length: 1 }).notNull(),
250251
columnDefault: binary('column_default', { length: 12 }),
251252
}),
253+
254+
allVectors: singlestoreTable('all_vectors', {
255+
vectorSimple: vector('vector_simple', { dimensions: 1 }),
256+
vectorElementType: vector('vector_element_type', { dimensions: 1, elementType: 'I8' }),
257+
vectorNotNull: vector('vector_not_null', { dimensions: 1 }).notNull(),
258+
vectorDefault: vector('vector_default', { dimensions: 1 }).default([1]),
259+
}),
252260
};
253261

254262
const { statements } = await diffTestSchemasPushSingleStore(

drizzle-orm/src/singlestore-core/columns/all.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { timestamp } from './timestamp.ts';
2121
import { tinyint } from './tinyint.ts';
2222
import { varbinary } from './varbinary.ts';
2323
import { varchar } from './varchar.ts';
24+
import { vector } from './vector.ts';
2425
import { year } from './year.ts';
2526

2627
export function getSingleStoreColumnBuilders() {
@@ -51,6 +52,7 @@ export function getSingleStoreColumnBuilders() {
5152
tinyint,
5253
varbinary,
5354
varchar,
55+
vector,
5456
year,
5557
};
5658
}

0 commit comments

Comments
 (0)