mirror of
https://github.com/kunkunsh/kunkun.git
synced 2025-04-20 05:29:17 +00:00
feat: add drizzle orm
This commit is contained in:
parent
c39e98258c
commit
68857a6f6d
34
packages/drizzle/.gitignore
vendored
Normal file
34
packages/drizzle/.gitignore
vendored
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
# dependencies (bun install)
|
||||||
|
node_modules
|
||||||
|
|
||||||
|
# output
|
||||||
|
out
|
||||||
|
dist
|
||||||
|
*.tgz
|
||||||
|
|
||||||
|
# code coverage
|
||||||
|
coverage
|
||||||
|
*.lcov
|
||||||
|
|
||||||
|
# logs
|
||||||
|
logs
|
||||||
|
_.log
|
||||||
|
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
|
||||||
|
|
||||||
|
# dotenv environment variable files
|
||||||
|
.env
|
||||||
|
.env.development.local
|
||||||
|
.env.test.local
|
||||||
|
.env.production.local
|
||||||
|
.env.local
|
||||||
|
|
||||||
|
# caches
|
||||||
|
.eslintcache
|
||||||
|
.cache
|
||||||
|
*.tsbuildinfo
|
||||||
|
|
||||||
|
# IntelliJ based IDEs
|
||||||
|
.idea
|
||||||
|
|
||||||
|
# Finder (MacOS) folder config
|
||||||
|
.DS_Store
|
1
packages/drizzle/README.md
Normal file
1
packages/drizzle/README.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
# drizzle
|
12
packages/drizzle/drizzle.config.ts
Normal file
12
packages/drizzle/drizzle.config.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import "dotenv/config"
|
||||||
|
import { defineConfig } from "drizzle-kit"
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
out: "./drizzle",
|
||||||
|
// schema: "./src/db/schema.ts",
|
||||||
|
dialect: "sqlite",
|
||||||
|
dbCredentials: {
|
||||||
|
url: "/Users/hk/Library/Application Support/sh.kunkun.desktop/kk.dev.sqlite"
|
||||||
|
// url: process.env.DB_FILE_NAME!
|
||||||
|
}
|
||||||
|
})
|
71
packages/drizzle/drizzle/0000_colossal_jocasta.sql
Normal file
71
packages/drizzle/drizzle/0000_colossal_jocasta.sql
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
-- Current sql file was generated after introspecting the database
|
||||||
|
-- If you want to run this migration please uncomment this code before executing migrations
|
||||||
|
/*
|
||||||
|
CREATE TABLE `schema_version` (
|
||||||
|
`version` integer NOT NULL
|
||||||
|
);
|
||||||
|
--> statement-breakpoint
|
||||||
|
CREATE TABLE `extensions` (
|
||||||
|
`ext_id` integer PRIMARY KEY AUTOINCREMENT,
|
||||||
|
`identifier` text NOT NULL,
|
||||||
|
`version` text NOT NULL,
|
||||||
|
`enabled` numeric DEFAULT (TRUE),
|
||||||
|
`path` text,
|
||||||
|
`data` numeric,
|
||||||
|
`installed_at` numeric DEFAULT (CURRENT_TIMESTAMP)
|
||||||
|
);
|
||||||
|
--> statement-breakpoint
|
||||||
|
CREATE TABLE `commands` (
|
||||||
|
`cmd_id` integer PRIMARY KEY AUTOINCREMENT,
|
||||||
|
`ext_id` integer NOT NULL,
|
||||||
|
`name` text NOT NULL,
|
||||||
|
`enabled` numeric DEFAULT (TRUE),
|
||||||
|
`alias` text,
|
||||||
|
`hotkey` text,
|
||||||
|
`type` text NOT NULL,
|
||||||
|
`data` numeric,
|
||||||
|
FOREIGN KEY (`ext_id`) REFERENCES `extensions`(`ext_id`) ON UPDATE no action ON DELETE cascade
|
||||||
|
);
|
||||||
|
--> statement-breakpoint
|
||||||
|
CREATE TABLE `extension_data` (
|
||||||
|
`data_id` integer PRIMARY KEY AUTOINCREMENT,
|
||||||
|
`ext_id` integer NOT NULL,
|
||||||
|
`data_type` text NOT NULL,
|
||||||
|
`data` numeric NOT NULL,
|
||||||
|
`metadata` numeric,
|
||||||
|
`search_text` text,
|
||||||
|
`created_at` numeric DEFAULT (CURRENT_TIMESTAMP),
|
||||||
|
`updated_at` numeric DEFAULT (CURRENT_TIMESTAMP),
|
||||||
|
FOREIGN KEY (`ext_id`) REFERENCES `extensions`(`ext_id`) ON UPDATE no action ON DELETE cascade
|
||||||
|
);
|
||||||
|
--> statement-breakpoint
|
||||||
|
CREATE TABLE `extension_data_fts` (
|
||||||
|
`data_id` numeric,
|
||||||
|
`search_text` numeric,
|
||||||
|
`extension_data_fts` numeric,
|
||||||
|
`rank` numeric
|
||||||
|
);
|
||||||
|
--> statement-breakpoint
|
||||||
|
CREATE TABLE `extension_data_fts_data` (
|
||||||
|
`id` integer PRIMARY KEY,
|
||||||
|
`block` blob
|
||||||
|
);
|
||||||
|
--> statement-breakpoint
|
||||||
|
CREATE TABLE `extension_data_fts_idx` (
|
||||||
|
`segid` numeric NOT NULL,
|
||||||
|
`term` numeric NOT NULL,
|
||||||
|
`pgno` numeric,
|
||||||
|
PRIMARY KEY(`segid`, `term`)
|
||||||
|
);
|
||||||
|
--> statement-breakpoint
|
||||||
|
CREATE TABLE `extension_data_fts_docsize` (
|
||||||
|
`id` integer PRIMARY KEY,
|
||||||
|
`sz` blob
|
||||||
|
);
|
||||||
|
--> statement-breakpoint
|
||||||
|
CREATE TABLE `extension_data_fts_config` (
|
||||||
|
`k` numeric PRIMARY KEY NOT NULL,
|
||||||
|
`v` numeric
|
||||||
|
);
|
||||||
|
|
||||||
|
*/
|
405
packages/drizzle/drizzle/meta/0000_snapshot.json
Normal file
405
packages/drizzle/drizzle/meta/0000_snapshot.json
Normal file
@ -0,0 +1,405 @@
|
|||||||
|
{
|
||||||
|
"id": "00000000-0000-0000-0000-000000000000",
|
||||||
|
"prevId": "",
|
||||||
|
"version": "6",
|
||||||
|
"dialect": "sqlite",
|
||||||
|
"tables": {
|
||||||
|
"schema_version": {
|
||||||
|
"name": "schema_version",
|
||||||
|
"columns": {
|
||||||
|
"version": {
|
||||||
|
"autoincrement": false,
|
||||||
|
"name": "version",
|
||||||
|
"type": "integer",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"compositePrimaryKeys": {},
|
||||||
|
"indexes": {},
|
||||||
|
"foreignKeys": {},
|
||||||
|
"uniqueConstraints": {},
|
||||||
|
"checkConstraints": {}
|
||||||
|
},
|
||||||
|
"extensions": {
|
||||||
|
"name": "extensions",
|
||||||
|
"columns": {
|
||||||
|
"ext_id": {
|
||||||
|
"autoincrement": true,
|
||||||
|
"name": "ext_id",
|
||||||
|
"type": "integer",
|
||||||
|
"primaryKey": true,
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
"identifier": {
|
||||||
|
"autoincrement": false,
|
||||||
|
"name": "identifier",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
"version": {
|
||||||
|
"autoincrement": false,
|
||||||
|
"name": "version",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
"enabled": {
|
||||||
|
"default": "(TRUE)",
|
||||||
|
"autoincrement": false,
|
||||||
|
"name": "enabled",
|
||||||
|
"type": "numeric",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
"path": {
|
||||||
|
"autoincrement": false,
|
||||||
|
"name": "path",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
"data": {
|
||||||
|
"autoincrement": false,
|
||||||
|
"name": "data",
|
||||||
|
"type": "numeric",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
"installed_at": {
|
||||||
|
"default": "(CURRENT_TIMESTAMP)",
|
||||||
|
"autoincrement": false,
|
||||||
|
"name": "installed_at",
|
||||||
|
"type": "numeric",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"compositePrimaryKeys": {},
|
||||||
|
"indexes": {},
|
||||||
|
"foreignKeys": {},
|
||||||
|
"uniqueConstraints": {},
|
||||||
|
"checkConstraints": {}
|
||||||
|
},
|
||||||
|
"commands": {
|
||||||
|
"name": "commands",
|
||||||
|
"columns": {
|
||||||
|
"cmd_id": {
|
||||||
|
"autoincrement": true,
|
||||||
|
"name": "cmd_id",
|
||||||
|
"type": "integer",
|
||||||
|
"primaryKey": true,
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
"ext_id": {
|
||||||
|
"autoincrement": false,
|
||||||
|
"name": "ext_id",
|
||||||
|
"type": "integer",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"autoincrement": false,
|
||||||
|
"name": "name",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
"enabled": {
|
||||||
|
"default": "(TRUE)",
|
||||||
|
"autoincrement": false,
|
||||||
|
"name": "enabled",
|
||||||
|
"type": "numeric",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
"alias": {
|
||||||
|
"autoincrement": false,
|
||||||
|
"name": "alias",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
"hotkey": {
|
||||||
|
"autoincrement": false,
|
||||||
|
"name": "hotkey",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
"autoincrement": false,
|
||||||
|
"name": "type",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
"data": {
|
||||||
|
"autoincrement": false,
|
||||||
|
"name": "data",
|
||||||
|
"type": "numeric",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"compositePrimaryKeys": {},
|
||||||
|
"indexes": {},
|
||||||
|
"foreignKeys": {
|
||||||
|
"commands_ext_id_extensions_ext_id_fk": {
|
||||||
|
"name": "commands_ext_id_extensions_ext_id_fk",
|
||||||
|
"tableFrom": "commands",
|
||||||
|
"tableTo": "extensions",
|
||||||
|
"columnsFrom": [
|
||||||
|
"ext_id"
|
||||||
|
],
|
||||||
|
"columnsTo": [
|
||||||
|
"ext_id"
|
||||||
|
],
|
||||||
|
"onDelete": "cascade",
|
||||||
|
"onUpdate": "no action"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"uniqueConstraints": {},
|
||||||
|
"checkConstraints": {}
|
||||||
|
},
|
||||||
|
"extension_data": {
|
||||||
|
"name": "extension_data",
|
||||||
|
"columns": {
|
||||||
|
"data_id": {
|
||||||
|
"autoincrement": true,
|
||||||
|
"name": "data_id",
|
||||||
|
"type": "integer",
|
||||||
|
"primaryKey": true,
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
"ext_id": {
|
||||||
|
"autoincrement": false,
|
||||||
|
"name": "ext_id",
|
||||||
|
"type": "integer",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
"data_type": {
|
||||||
|
"autoincrement": false,
|
||||||
|
"name": "data_type",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
"data": {
|
||||||
|
"autoincrement": false,
|
||||||
|
"name": "data",
|
||||||
|
"type": "numeric",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
"metadata": {
|
||||||
|
"autoincrement": false,
|
||||||
|
"name": "metadata",
|
||||||
|
"type": "numeric",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
"search_text": {
|
||||||
|
"autoincrement": false,
|
||||||
|
"name": "search_text",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
"created_at": {
|
||||||
|
"default": "(CURRENT_TIMESTAMP)",
|
||||||
|
"autoincrement": false,
|
||||||
|
"name": "created_at",
|
||||||
|
"type": "numeric",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
"updated_at": {
|
||||||
|
"default": "(CURRENT_TIMESTAMP)",
|
||||||
|
"autoincrement": false,
|
||||||
|
"name": "updated_at",
|
||||||
|
"type": "numeric",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"compositePrimaryKeys": {},
|
||||||
|
"indexes": {},
|
||||||
|
"foreignKeys": {
|
||||||
|
"extension_data_ext_id_extensions_ext_id_fk": {
|
||||||
|
"name": "extension_data_ext_id_extensions_ext_id_fk",
|
||||||
|
"tableFrom": "extension_data",
|
||||||
|
"tableTo": "extensions",
|
||||||
|
"columnsFrom": [
|
||||||
|
"ext_id"
|
||||||
|
],
|
||||||
|
"columnsTo": [
|
||||||
|
"ext_id"
|
||||||
|
],
|
||||||
|
"onDelete": "cascade",
|
||||||
|
"onUpdate": "no action"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"uniqueConstraints": {},
|
||||||
|
"checkConstraints": {}
|
||||||
|
},
|
||||||
|
"extension_data_fts": {
|
||||||
|
"name": "extension_data_fts",
|
||||||
|
"columns": {
|
||||||
|
"data_id": {
|
||||||
|
"autoincrement": false,
|
||||||
|
"name": "data_id",
|
||||||
|
"type": "numeric",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
"search_text": {
|
||||||
|
"autoincrement": false,
|
||||||
|
"name": "search_text",
|
||||||
|
"type": "numeric",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
"extension_data_fts": {
|
||||||
|
"autoincrement": false,
|
||||||
|
"name": "extension_data_fts",
|
||||||
|
"type": "numeric",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
"rank": {
|
||||||
|
"autoincrement": false,
|
||||||
|
"name": "rank",
|
||||||
|
"type": "numeric",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"compositePrimaryKeys": {},
|
||||||
|
"indexes": {},
|
||||||
|
"foreignKeys": {},
|
||||||
|
"uniqueConstraints": {},
|
||||||
|
"checkConstraints": {}
|
||||||
|
},
|
||||||
|
"extension_data_fts_data": {
|
||||||
|
"name": "extension_data_fts_data",
|
||||||
|
"columns": {
|
||||||
|
"id": {
|
||||||
|
"autoincrement": false,
|
||||||
|
"name": "id",
|
||||||
|
"type": "integer",
|
||||||
|
"primaryKey": true,
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
"block": {
|
||||||
|
"autoincrement": false,
|
||||||
|
"name": "block",
|
||||||
|
"type": "blob",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"compositePrimaryKeys": {},
|
||||||
|
"indexes": {},
|
||||||
|
"foreignKeys": {},
|
||||||
|
"uniqueConstraints": {},
|
||||||
|
"checkConstraints": {}
|
||||||
|
},
|
||||||
|
"extension_data_fts_idx": {
|
||||||
|
"name": "extension_data_fts_idx",
|
||||||
|
"columns": {
|
||||||
|
"segid": {
|
||||||
|
"autoincrement": false,
|
||||||
|
"name": "segid",
|
||||||
|
"type": "numeric",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
"term": {
|
||||||
|
"autoincrement": false,
|
||||||
|
"name": "term",
|
||||||
|
"type": "numeric",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
"pgno": {
|
||||||
|
"autoincrement": false,
|
||||||
|
"name": "pgno",
|
||||||
|
"type": "numeric",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"compositePrimaryKeys": {
|
||||||
|
"extension_data_fts_idx_segid_term_pk": {
|
||||||
|
"columns": [
|
||||||
|
"segid",
|
||||||
|
"term"
|
||||||
|
],
|
||||||
|
"name": "extension_data_fts_idx_segid_term_pk"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"indexes": {},
|
||||||
|
"foreignKeys": {},
|
||||||
|
"uniqueConstraints": {},
|
||||||
|
"checkConstraints": {}
|
||||||
|
},
|
||||||
|
"extension_data_fts_docsize": {
|
||||||
|
"name": "extension_data_fts_docsize",
|
||||||
|
"columns": {
|
||||||
|
"id": {
|
||||||
|
"autoincrement": false,
|
||||||
|
"name": "id",
|
||||||
|
"type": "integer",
|
||||||
|
"primaryKey": true,
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
"sz": {
|
||||||
|
"autoincrement": false,
|
||||||
|
"name": "sz",
|
||||||
|
"type": "blob",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"compositePrimaryKeys": {},
|
||||||
|
"indexes": {},
|
||||||
|
"foreignKeys": {},
|
||||||
|
"uniqueConstraints": {},
|
||||||
|
"checkConstraints": {}
|
||||||
|
},
|
||||||
|
"extension_data_fts_config": {
|
||||||
|
"name": "extension_data_fts_config",
|
||||||
|
"columns": {
|
||||||
|
"k": {
|
||||||
|
"autoincrement": false,
|
||||||
|
"name": "k",
|
||||||
|
"type": "numeric",
|
||||||
|
"primaryKey": true,
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
"v": {
|
||||||
|
"autoincrement": false,
|
||||||
|
"name": "v",
|
||||||
|
"type": "numeric",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"compositePrimaryKeys": {},
|
||||||
|
"indexes": {},
|
||||||
|
"foreignKeys": {},
|
||||||
|
"uniqueConstraints": {},
|
||||||
|
"checkConstraints": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"views": {},
|
||||||
|
"enums": {},
|
||||||
|
"_meta": {
|
||||||
|
"schemas": {},
|
||||||
|
"tables": {},
|
||||||
|
"columns": {}
|
||||||
|
}
|
||||||
|
}
|
13
packages/drizzle/drizzle/meta/_journal.json
Normal file
13
packages/drizzle/drizzle/meta/_journal.json
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"version": "7",
|
||||||
|
"dialect": "sqlite",
|
||||||
|
"entries": [
|
||||||
|
{
|
||||||
|
"idx": 0,
|
||||||
|
"version": "6",
|
||||||
|
"when": 1742544246324,
|
||||||
|
"tag": "0000_colossal_jocasta",
|
||||||
|
"breakpoints": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
21
packages/drizzle/drizzle/relations.ts
Normal file
21
packages/drizzle/drizzle/relations.ts
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import { relations } from "drizzle-orm/relations";
|
||||||
|
import { extensions, commands, extensionData } from "./schema";
|
||||||
|
|
||||||
|
export const commandsRelations = relations(commands, ({one}) => ({
|
||||||
|
extension: one(extensions, {
|
||||||
|
fields: [commands.extId],
|
||||||
|
references: [extensions.extId]
|
||||||
|
}),
|
||||||
|
}));
|
||||||
|
|
||||||
|
export const extensionsRelations = relations(extensions, ({many}) => ({
|
||||||
|
commands: many(commands),
|
||||||
|
extensionData: many(extensionData),
|
||||||
|
}));
|
||||||
|
|
||||||
|
export const extensionDataRelations = relations(extensionData, ({one}) => ({
|
||||||
|
extension: one(extensions, {
|
||||||
|
fields: [extensionData.extId],
|
||||||
|
references: [extensions.extId]
|
||||||
|
}),
|
||||||
|
}));
|
70
packages/drizzle/drizzle/schema.ts
Normal file
70
packages/drizzle/drizzle/schema.ts
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
import { sqliteTable, AnySQLiteColumn, integer, text, numeric, foreignKey, blob, primaryKey } from "drizzle-orm/sqlite-core"
|
||||||
|
import { sql } from "drizzle-orm"
|
||||||
|
|
||||||
|
export const schemaVersion = sqliteTable("schema_version", {
|
||||||
|
version: integer().notNull(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const extensions = sqliteTable("extensions", {
|
||||||
|
extId: integer("ext_id").primaryKey({ autoIncrement: true }),
|
||||||
|
identifier: text().notNull(),
|
||||||
|
version: text().notNull(),
|
||||||
|
enabled: numeric().default(sql`(TRUE)`),
|
||||||
|
path: text(),
|
||||||
|
data: numeric(),
|
||||||
|
installedAt: numeric("installed_at").default(sql`(CURRENT_TIMESTAMP)`),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const commands = sqliteTable("commands", {
|
||||||
|
cmdId: integer("cmd_id").primaryKey({ autoIncrement: true }),
|
||||||
|
extId: integer("ext_id").notNull().references(() => extensions.extId, { onDelete: "cascade" } ),
|
||||||
|
name: text().notNull(),
|
||||||
|
enabled: numeric().default(sql`(TRUE)`),
|
||||||
|
alias: text(),
|
||||||
|
hotkey: text(),
|
||||||
|
type: text().notNull(),
|
||||||
|
data: numeric(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const extensionData = sqliteTable("extension_data", {
|
||||||
|
dataId: integer("data_id").primaryKey({ autoIncrement: true }),
|
||||||
|
extId: integer("ext_id").notNull().references(() => extensions.extId, { onDelete: "cascade" } ),
|
||||||
|
dataType: text("data_type").notNull(),
|
||||||
|
data: numeric().notNull(),
|
||||||
|
metadata: numeric(),
|
||||||
|
searchText: text("search_text"),
|
||||||
|
createdAt: numeric("created_at").default(sql`(CURRENT_TIMESTAMP)`),
|
||||||
|
updatedAt: numeric("updated_at").default(sql`(CURRENT_TIMESTAMP)`),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const extensionDataFts = sqliteTable("extension_data_fts", {
|
||||||
|
dataId: numeric("data_id"),
|
||||||
|
searchText: numeric("search_text"),
|
||||||
|
extensionDataFts: numeric("extension_data_fts"),
|
||||||
|
rank: numeric(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const extensionDataFtsData = sqliteTable("extension_data_fts_data", {
|
||||||
|
id: integer().primaryKey(),
|
||||||
|
block: blob(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const extensionDataFtsIdx = sqliteTable("extension_data_fts_idx", {
|
||||||
|
segid: numeric().notNull(),
|
||||||
|
term: numeric().notNull(),
|
||||||
|
pgno: numeric(),
|
||||||
|
},
|
||||||
|
(table) => [
|
||||||
|
primaryKey({ columns: [table.segid, table.term], name: "extension_data_fts_idx_segid_term_pk"})
|
||||||
|
]);
|
||||||
|
|
||||||
|
export const extensionDataFtsDocsize = sqliteTable("extension_data_fts_docsize", {
|
||||||
|
id: integer().primaryKey(),
|
||||||
|
sz: blob(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const extensionDataFtsConfig = sqliteTable("extension_data_fts_config", {
|
||||||
|
k: numeric().primaryKey().notNull(),
|
||||||
|
v: numeric(),
|
||||||
|
});
|
||||||
|
|
1
packages/drizzle/index.ts
Normal file
1
packages/drizzle/index.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
console.log("Hello via Bun!");
|
19
packages/drizzle/package.json
Normal file
19
packages/drizzle/package.json
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"name": "drizzle",
|
||||||
|
"module": "index.ts",
|
||||||
|
"type": "module",
|
||||||
|
"private": true,
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/bun": "latest",
|
||||||
|
"drizzle-kit": "^0.30.5",
|
||||||
|
"tsx": "^4.19.3"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"typescript": "^5"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@libsql/client": "^0.15.0",
|
||||||
|
"dotenv": "^16.4.7",
|
||||||
|
"drizzle-orm": "^0.40.1"
|
||||||
|
}
|
||||||
|
}
|
28
packages/drizzle/tsconfig.json
Normal file
28
packages/drizzle/tsconfig.json
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
// Environment setup & latest features
|
||||||
|
"lib": ["esnext"],
|
||||||
|
"target": "ESNext",
|
||||||
|
"module": "ESNext",
|
||||||
|
"moduleDetection": "force",
|
||||||
|
"jsx": "react-jsx",
|
||||||
|
"allowJs": true,
|
||||||
|
|
||||||
|
// Bundler mode
|
||||||
|
"moduleResolution": "bundler",
|
||||||
|
"allowImportingTsExtensions": true,
|
||||||
|
"verbatimModuleSyntax": true,
|
||||||
|
"noEmit": true,
|
||||||
|
|
||||||
|
// Best practices
|
||||||
|
"strict": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"noFallthroughCasesInSwitch": true,
|
||||||
|
"noUncheckedIndexedAccess": true,
|
||||||
|
|
||||||
|
// Some stricter flags (disabled by default)
|
||||||
|
"noUnusedLocals": false,
|
||||||
|
"noUnusedParameters": false,
|
||||||
|
"noPropertyAccessFromIndexSignature": false
|
||||||
|
}
|
||||||
|
}
|
1026
pnpm-lock.yaml
generated
1026
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user