Skip to content

Commit 49d2930

Browse files
Merge pull request #3916 from drizzle-team/beta
Beta
2 parents 04c9143 + 9927cf1 commit 49d2930

File tree

17 files changed

+224
-21
lines changed

17 files changed

+224
-21
lines changed

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-orm/0.38.4.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
- New SingleStore type `vector` - thanks @mitchwadair
2+
- Fix wrong DROP INDEX statement generation, [#3866](https://github.com/drizzle-team/drizzle-orm/pull/3866) - thanks @WaciX
3+
- Typo fixes - thanks @stephan281094

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/sqlgenerator.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3557,8 +3557,12 @@ class PgDropIndexConvertor extends Convertor {
35573557
}
35583558

35593559
convert(statement: JsonDropIndexStatement): string {
3560+
const { schema } = statement;
35603561
const { name } = PgSquasher.unsquashIdx(statement.data);
3561-
return `DROP INDEX "${name}";`;
3562+
3563+
const indexNameWithSchema = schema ? `"${schema}"."${name}"` : `"${name}"`;
3564+
3565+
return `DROP INDEX ${indexNameWithSchema};`;
35623566
}
35633567
}
35643568

drizzle-kit/src/utils/certs.ts

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,38 @@
11
import envPaths from 'env-paths';
22
import { mkdirSync } from 'fs';
33
import { access, readFile } from 'fs/promises';
4+
import { exec, ExecOptions } from 'node:child_process';
45
import { join } from 'path';
5-
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 });
7+
export function runCommand(command: string, options: ExecOptions = {}) {
8+
return new Promise<{ exitCode: number }>((resolve) => {
9+
exec(command, options, (error) => {
10+
return resolve({ exitCode: error?.code ?? 0 });
11+
});
12+
});
13+
}
1414

1515
export const certs = async () => {
16-
const res = await $`mkcert --help`.nothrow();
17-
18-
// ~/.local/share/drizzle-studio
19-
const keyPath = join(p.data, 'localhost-key.pem');
20-
const certPath = join(p.data, 'localhost.pem');
16+
const res = await runCommand('mkcert --help');
2117

2218
if (res.exitCode === 0) {
19+
const p = envPaths('drizzle-studio', {
20+
suffix: '',
21+
});
22+
23+
// create ~/.local/share/drizzle-studio
24+
mkdirSync(p.data, { recursive: true });
25+
26+
// ~/.local/share/drizzle-studio
27+
const keyPath = join(p.data, 'localhost-key.pem');
28+
const certPath = join(p.data, 'localhost.pem');
29+
2330
try {
31+
// check if the files exist
2432
await Promise.all([access(keyPath), access(certPath)]);
2533
} catch (e) {
26-
await $`mkcert localhost`.nothrow();
34+
// if not create them
35+
await runCommand(`mkcert localhost`, { cwd: p.data });
2736
}
2837
const [key, cert] = await Promise.all([
2938
readFile(keyPath, { encoding: 'utf-8' }),
@@ -33,5 +42,3 @@ export const certs = async () => {
3342
}
3443
return null;
3544
};
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/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "drizzle-orm",
3-
"version": "0.38.3",
3+
"version": "0.38.4",
44
"description": "Drizzle ORM package for SQL databases",
55
"type": "module",
66
"scripts": {

0 commit comments

Comments
 (0)