Restore Ultracite + fix sidebar (#1233)

This commit is contained in:
Hayden Bleasel 2025-09-21 11:02:31 -07:00 committed by GitHub
parent 8fbfc253fa
commit 947ed094a6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
177 changed files with 6908 additions and 8306 deletions

View file

@ -1,32 +1,32 @@
import { config } from 'dotenv';
import { drizzle } from 'drizzle-orm/postgres-js';
import { migrate } from 'drizzle-orm/postgres-js/migrator';
import postgres from 'postgres';
import { config } from "dotenv";
import { drizzle } from "drizzle-orm/postgres-js";
import { migrate } from "drizzle-orm/postgres-js/migrator";
import postgres from "postgres";
config({
path: '.env.local',
path: ".env.local",
});
const runMigrate = async () => {
if (!process.env.POSTGRES_URL) {
throw new Error('POSTGRES_URL is not defined');
throw new Error("POSTGRES_URL is not defined");
}
const connection = postgres(process.env.POSTGRES_URL, { max: 1 });
const db = drizzle(connection);
console.log('⏳ Running migrations...');
console.log("⏳ Running migrations...");
const start = Date.now();
await migrate(db, { migrationsFolder: './lib/db/migrations' });
await migrate(db, { migrationsFolder: "./lib/db/migrations" });
const end = Date.now();
console.log('✅ Migrations completed in', end - start, 'ms');
console.log("✅ Migrations completed in", end - start, "ms");
process.exit(0);
};
runMigrate().catch((err) => {
console.error('❌ Migration failed');
console.error("❌ Migration failed");
console.error(err);
process.exit(1);
});

View file

@ -40,12 +40,8 @@
"name": "Chat_userId_User_id_fk",
"tableFrom": "Chat",
"tableTo": "User",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"columnsFrom": ["userId"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
}
@ -91,4 +87,4 @@
"schemas": {},
"tables": {}
}
}
}

View file

@ -71,12 +71,8 @@
"name": "Suggestion_userId_User_id_fk",
"tableFrom": "Suggestion",
"tableTo": "User",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"columnsFrom": ["userId"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
},
@ -84,14 +80,8 @@
"name": "Suggestion_documentId_documentCreatedAt_Document_id_createdAt_fk",
"tableFrom": "Suggestion",
"tableTo": "Document",
"columnsFrom": [
"documentId",
"documentCreatedAt"
],
"columnsTo": [
"id",
"createdAt"
],
"columnsFrom": ["documentId", "documentCreatedAt"],
"columnsTo": ["id", "createdAt"],
"onDelete": "no action",
"onUpdate": "no action"
}
@ -99,9 +89,7 @@
"compositePrimaryKeys": {
"Suggestion_id_pk": {
"name": "Suggestion_id_pk",
"columns": [
"id"
]
"columns": ["id"]
}
},
"uniqueConstraints": {}
@ -142,12 +130,8 @@
"name": "Chat_userId_User_id_fk",
"tableFrom": "Chat",
"tableTo": "User",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"columnsFrom": ["userId"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
}
@ -197,12 +181,8 @@
"name": "Document_userId_User_id_fk",
"tableFrom": "Document",
"tableTo": "User",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"columnsFrom": ["userId"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
}
@ -210,10 +190,7 @@
"compositePrimaryKeys": {
"Document_id_createdAt_pk": {
"name": "Document_id_createdAt_pk",
"columns": [
"id",
"createdAt"
]
"columns": ["id", "createdAt"]
}
},
"uniqueConstraints": {}
@ -256,4 +233,4 @@
"schemas": {},
"tables": {}
}
}
}

View file

@ -71,12 +71,8 @@
"name": "Suggestion_userId_User_id_fk",
"tableFrom": "Suggestion",
"tableTo": "User",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"columnsFrom": ["userId"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
},
@ -84,14 +80,8 @@
"name": "Suggestion_documentId_documentCreatedAt_Document_id_createdAt_fk",
"tableFrom": "Suggestion",
"tableTo": "Document",
"columnsFrom": [
"documentId",
"documentCreatedAt"
],
"columnsTo": [
"id",
"createdAt"
],
"columnsFrom": ["documentId", "documentCreatedAt"],
"columnsTo": ["id", "createdAt"],
"onDelete": "no action",
"onUpdate": "no action"
}
@ -99,9 +89,7 @@
"compositePrimaryKeys": {
"Suggestion_id_pk": {
"name": "Suggestion_id_pk",
"columns": [
"id"
]
"columns": ["id"]
}
},
"uniqueConstraints": {}
@ -142,12 +130,8 @@
"name": "Chat_userId_User_id_fk",
"tableFrom": "Chat",
"tableTo": "User",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"columnsFrom": ["userId"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
}
@ -197,12 +181,8 @@
"name": "Document_userId_User_id_fk",
"tableFrom": "Document",
"tableTo": "User",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"columnsFrom": ["userId"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
}
@ -210,10 +190,7 @@
"compositePrimaryKeys": {
"Document_id_createdAt_pk": {
"name": "Document_id_createdAt_pk",
"columns": [
"id",
"createdAt"
]
"columns": ["id", "createdAt"]
}
},
"uniqueConstraints": {}
@ -260,12 +237,8 @@
"name": "Message_chatId_Chat_id_fk",
"tableFrom": "Message",
"tableTo": "Chat",
"columnsFrom": [
"chatId"
],
"columnsTo": [
"id"
],
"columnsFrom": ["chatId"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
}
@ -331,12 +304,8 @@
"name": "Vote_chatId_Chat_id_fk",
"tableFrom": "Vote",
"tableTo": "Chat",
"columnsFrom": [
"chatId"
],
"columnsTo": [
"id"
],
"columnsFrom": ["chatId"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
},
@ -344,12 +313,8 @@
"name": "Vote_messageId_Message_id_fk",
"tableFrom": "Vote",
"tableTo": "Message",
"columnsFrom": [
"messageId"
],
"columnsTo": [
"id"
],
"columnsFrom": ["messageId"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
}
@ -357,10 +322,7 @@
"compositePrimaryKeys": {
"Vote_chatId_messageId_pk": {
"name": "Vote_chatId_messageId_pk",
"columns": [
"chatId",
"messageId"
]
"columns": ["chatId", "messageId"]
}
},
"uniqueConstraints": {}
@ -374,4 +336,4 @@
"schemas": {},
"tables": {}
}
}
}

View file

@ -47,12 +47,8 @@
"name": "Chat_userId_User_id_fk",
"tableFrom": "Chat",
"tableTo": "User",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"columnsFrom": ["userId"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
}
@ -102,12 +98,8 @@
"name": "Document_userId_User_id_fk",
"tableFrom": "Document",
"tableTo": "User",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"columnsFrom": ["userId"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
}
@ -115,10 +107,7 @@
"compositePrimaryKeys": {
"Document_id_createdAt_pk": {
"name": "Document_id_createdAt_pk",
"columns": [
"id",
"createdAt"
]
"columns": ["id", "createdAt"]
}
},
"uniqueConstraints": {}
@ -165,12 +154,8 @@
"name": "Message_chatId_Chat_id_fk",
"tableFrom": "Message",
"tableTo": "Chat",
"columnsFrom": [
"chatId"
],
"columnsTo": [
"id"
],
"columnsFrom": ["chatId"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
}
@ -245,12 +230,8 @@
"name": "Suggestion_userId_User_id_fk",
"tableFrom": "Suggestion",
"tableTo": "User",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"columnsFrom": ["userId"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
},
@ -258,14 +239,8 @@
"name": "Suggestion_documentId_documentCreatedAt_Document_id_createdAt_fk",
"tableFrom": "Suggestion",
"tableTo": "Document",
"columnsFrom": [
"documentId",
"documentCreatedAt"
],
"columnsTo": [
"id",
"createdAt"
],
"columnsFrom": ["documentId", "documentCreatedAt"],
"columnsTo": ["id", "createdAt"],
"onDelete": "no action",
"onUpdate": "no action"
}
@ -273,9 +248,7 @@
"compositePrimaryKeys": {
"Suggestion_id_pk": {
"name": "Suggestion_id_pk",
"columns": [
"id"
]
"columns": ["id"]
}
},
"uniqueConstraints": {}
@ -338,12 +311,8 @@
"name": "Vote_chatId_Chat_id_fk",
"tableFrom": "Vote",
"tableTo": "Chat",
"columnsFrom": [
"chatId"
],
"columnsTo": [
"id"
],
"columnsFrom": ["chatId"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
},
@ -351,12 +320,8 @@
"name": "Vote_messageId_Message_id_fk",
"tableFrom": "Vote",
"tableTo": "Message",
"columnsFrom": [
"messageId"
],
"columnsTo": [
"id"
],
"columnsFrom": ["messageId"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
}
@ -364,10 +329,7 @@
"compositePrimaryKeys": {
"Vote_chatId_messageId_pk": {
"name": "Vote_chatId_messageId_pk",
"columns": [
"chatId",
"messageId"
]
"columns": ["chatId", "messageId"]
}
},
"uniqueConstraints": {}
@ -381,4 +343,4 @@
"schemas": {},
"tables": {}
}
}
}

View file

@ -47,12 +47,8 @@
"name": "Chat_userId_User_id_fk",
"tableFrom": "Chat",
"tableTo": "User",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"columnsFrom": ["userId"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
}
@ -109,12 +105,8 @@
"name": "Document_userId_User_id_fk",
"tableFrom": "Document",
"tableTo": "User",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"columnsFrom": ["userId"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
}
@ -122,10 +114,7 @@
"compositePrimaryKeys": {
"Document_id_createdAt_pk": {
"name": "Document_id_createdAt_pk",
"columns": [
"id",
"createdAt"
]
"columns": ["id", "createdAt"]
}
},
"uniqueConstraints": {}
@ -172,12 +161,8 @@
"name": "Message_chatId_Chat_id_fk",
"tableFrom": "Message",
"tableTo": "Chat",
"columnsFrom": [
"chatId"
],
"columnsTo": [
"id"
],
"columnsFrom": ["chatId"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
}
@ -252,12 +237,8 @@
"name": "Suggestion_userId_User_id_fk",
"tableFrom": "Suggestion",
"tableTo": "User",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"columnsFrom": ["userId"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
},
@ -265,14 +246,8 @@
"name": "Suggestion_documentId_documentCreatedAt_Document_id_createdAt_fk",
"tableFrom": "Suggestion",
"tableTo": "Document",
"columnsFrom": [
"documentId",
"documentCreatedAt"
],
"columnsTo": [
"id",
"createdAt"
],
"columnsFrom": ["documentId", "documentCreatedAt"],
"columnsTo": ["id", "createdAt"],
"onDelete": "no action",
"onUpdate": "no action"
}
@ -280,9 +255,7 @@
"compositePrimaryKeys": {
"Suggestion_id_pk": {
"name": "Suggestion_id_pk",
"columns": [
"id"
]
"columns": ["id"]
}
},
"uniqueConstraints": {}
@ -345,12 +318,8 @@
"name": "Vote_chatId_Chat_id_fk",
"tableFrom": "Vote",
"tableTo": "Chat",
"columnsFrom": [
"chatId"
],
"columnsTo": [
"id"
],
"columnsFrom": ["chatId"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
},
@ -358,12 +327,8 @@
"name": "Vote_messageId_Message_id_fk",
"tableFrom": "Vote",
"tableTo": "Message",
"columnsFrom": [
"messageId"
],
"columnsTo": [
"id"
],
"columnsFrom": ["messageId"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
}
@ -371,10 +336,7 @@
"compositePrimaryKeys": {
"Vote_chatId_messageId_pk": {
"name": "Vote_chatId_messageId_pk",
"columns": [
"chatId",
"messageId"
]
"columns": ["chatId", "messageId"]
}
},
"uniqueConstraints": {}
@ -388,4 +350,4 @@
"schemas": {},
"tables": {}
}
}
}

View file

@ -47,12 +47,8 @@
"name": "Chat_userId_User_id_fk",
"tableFrom": "Chat",
"tableTo": "User",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"columnsFrom": ["userId"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
}
@ -109,12 +105,8 @@
"name": "Document_userId_User_id_fk",
"tableFrom": "Document",
"tableTo": "User",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"columnsFrom": ["userId"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
}
@ -122,10 +114,7 @@
"compositePrimaryKeys": {
"Document_id_createdAt_pk": {
"name": "Document_id_createdAt_pk",
"columns": [
"id",
"createdAt"
]
"columns": ["id", "createdAt"]
}
},
"uniqueConstraints": {}
@ -178,12 +167,8 @@
"name": "Message_v2_chatId_Chat_id_fk",
"tableFrom": "Message_v2",
"tableTo": "Chat",
"columnsFrom": [
"chatId"
],
"columnsTo": [
"id"
],
"columnsFrom": ["chatId"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
}
@ -233,12 +218,8 @@
"name": "Message_chatId_Chat_id_fk",
"tableFrom": "Message",
"tableTo": "Chat",
"columnsFrom": [
"chatId"
],
"columnsTo": [
"id"
],
"columnsFrom": ["chatId"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
}
@ -313,12 +294,8 @@
"name": "Suggestion_userId_User_id_fk",
"tableFrom": "Suggestion",
"tableTo": "User",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"columnsFrom": ["userId"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
},
@ -326,14 +303,8 @@
"name": "Suggestion_documentId_documentCreatedAt_Document_id_createdAt_fk",
"tableFrom": "Suggestion",
"tableTo": "Document",
"columnsFrom": [
"documentId",
"documentCreatedAt"
],
"columnsTo": [
"id",
"createdAt"
],
"columnsFrom": ["documentId", "documentCreatedAt"],
"columnsTo": ["id", "createdAt"],
"onDelete": "no action",
"onUpdate": "no action"
}
@ -341,9 +312,7 @@
"compositePrimaryKeys": {
"Suggestion_id_pk": {
"name": "Suggestion_id_pk",
"columns": [
"id"
]
"columns": ["id"]
}
},
"uniqueConstraints": {}
@ -406,12 +375,8 @@
"name": "Vote_v2_chatId_Chat_id_fk",
"tableFrom": "Vote_v2",
"tableTo": "Chat",
"columnsFrom": [
"chatId"
],
"columnsTo": [
"id"
],
"columnsFrom": ["chatId"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
},
@ -419,12 +384,8 @@
"name": "Vote_v2_messageId_Message_v2_id_fk",
"tableFrom": "Vote_v2",
"tableTo": "Message_v2",
"columnsFrom": [
"messageId"
],
"columnsTo": [
"id"
],
"columnsFrom": ["messageId"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
}
@ -432,10 +393,7 @@
"compositePrimaryKeys": {
"Vote_v2_chatId_messageId_pk": {
"name": "Vote_v2_chatId_messageId_pk",
"columns": [
"chatId",
"messageId"
]
"columns": ["chatId", "messageId"]
}
},
"uniqueConstraints": {}
@ -469,12 +427,8 @@
"name": "Vote_chatId_Chat_id_fk",
"tableFrom": "Vote",
"tableTo": "Chat",
"columnsFrom": [
"chatId"
],
"columnsTo": [
"id"
],
"columnsFrom": ["chatId"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
},
@ -482,12 +436,8 @@
"name": "Vote_messageId_Message_id_fk",
"tableFrom": "Vote",
"tableTo": "Message",
"columnsFrom": [
"messageId"
],
"columnsTo": [
"id"
],
"columnsFrom": ["messageId"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
}
@ -495,10 +445,7 @@
"compositePrimaryKeys": {
"Vote_chatId_messageId_pk": {
"name": "Vote_chatId_messageId_pk",
"columns": [
"chatId",
"messageId"
]
"columns": ["chatId", "messageId"]
}
},
"uniqueConstraints": {}
@ -512,4 +459,4 @@
"schemas": {},
"tables": {}
}
}
}

View file

@ -47,12 +47,8 @@
"name": "Chat_userId_User_id_fk",
"tableFrom": "Chat",
"tableTo": "User",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"columnsFrom": ["userId"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
}
@ -109,12 +105,8 @@
"name": "Document_userId_User_id_fk",
"tableFrom": "Document",
"tableTo": "User",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"columnsFrom": ["userId"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
}
@ -122,10 +114,7 @@
"compositePrimaryKeys": {
"Document_id_createdAt_pk": {
"name": "Document_id_createdAt_pk",
"columns": [
"id",
"createdAt"
]
"columns": ["id", "createdAt"]
}
},
"uniqueConstraints": {}
@ -178,12 +167,8 @@
"name": "Message_v2_chatId_Chat_id_fk",
"tableFrom": "Message_v2",
"tableTo": "Chat",
"columnsFrom": [
"chatId"
],
"columnsTo": [
"id"
],
"columnsFrom": ["chatId"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
}
@ -233,12 +218,8 @@
"name": "Message_chatId_Chat_id_fk",
"tableFrom": "Message",
"tableTo": "Chat",
"columnsFrom": [
"chatId"
],
"columnsTo": [
"id"
],
"columnsFrom": ["chatId"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
}
@ -276,12 +257,8 @@
"name": "Stream_chatId_Chat_id_fk",
"tableFrom": "Stream",
"tableTo": "Chat",
"columnsFrom": [
"chatId"
],
"columnsTo": [
"id"
],
"columnsFrom": ["chatId"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
}
@ -289,9 +266,7 @@
"compositePrimaryKeys": {
"Stream_id_pk": {
"name": "Stream_id_pk",
"columns": [
"id"
]
"columns": ["id"]
}
},
"uniqueConstraints": {}
@ -363,12 +338,8 @@
"name": "Suggestion_userId_User_id_fk",
"tableFrom": "Suggestion",
"tableTo": "User",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"columnsFrom": ["userId"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
},
@ -376,14 +347,8 @@
"name": "Suggestion_documentId_documentCreatedAt_Document_id_createdAt_fk",
"tableFrom": "Suggestion",
"tableTo": "Document",
"columnsFrom": [
"documentId",
"documentCreatedAt"
],
"columnsTo": [
"id",
"createdAt"
],
"columnsFrom": ["documentId", "documentCreatedAt"],
"columnsTo": ["id", "createdAt"],
"onDelete": "no action",
"onUpdate": "no action"
}
@ -391,9 +356,7 @@
"compositePrimaryKeys": {
"Suggestion_id_pk": {
"name": "Suggestion_id_pk",
"columns": [
"id"
]
"columns": ["id"]
}
},
"uniqueConstraints": {}
@ -456,12 +419,8 @@
"name": "Vote_v2_chatId_Chat_id_fk",
"tableFrom": "Vote_v2",
"tableTo": "Chat",
"columnsFrom": [
"chatId"
],
"columnsTo": [
"id"
],
"columnsFrom": ["chatId"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
},
@ -469,12 +428,8 @@
"name": "Vote_v2_messageId_Message_v2_id_fk",
"tableFrom": "Vote_v2",
"tableTo": "Message_v2",
"columnsFrom": [
"messageId"
],
"columnsTo": [
"id"
],
"columnsFrom": ["messageId"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
}
@ -482,10 +437,7 @@
"compositePrimaryKeys": {
"Vote_v2_chatId_messageId_pk": {
"name": "Vote_v2_chatId_messageId_pk",
"columns": [
"chatId",
"messageId"
]
"columns": ["chatId", "messageId"]
}
},
"uniqueConstraints": {}
@ -519,12 +471,8 @@
"name": "Vote_chatId_Chat_id_fk",
"tableFrom": "Vote",
"tableTo": "Chat",
"columnsFrom": [
"chatId"
],
"columnsTo": [
"id"
],
"columnsFrom": ["chatId"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
},
@ -532,12 +480,8 @@
"name": "Vote_messageId_Message_id_fk",
"tableFrom": "Vote",
"tableTo": "Message",
"columnsFrom": [
"messageId"
],
"columnsTo": [
"id"
],
"columnsFrom": ["messageId"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
}
@ -545,10 +489,7 @@
"compositePrimaryKeys": {
"Vote_chatId_messageId_pk": {
"name": "Vote_chatId_messageId_pk",
"columns": [
"chatId",
"messageId"
]
"columns": ["chatId", "messageId"]
}
},
"uniqueConstraints": {}
@ -562,4 +503,4 @@
"schemas": {},
"tables": {}
}
}
}

View file

@ -53,12 +53,8 @@
"name": "Chat_userId_User_id_fk",
"tableFrom": "Chat",
"tableTo": "User",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"columnsFrom": ["userId"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
}
@ -115,12 +111,8 @@
"name": "Document_userId_User_id_fk",
"tableFrom": "Document",
"tableTo": "User",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"columnsFrom": ["userId"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
}
@ -128,10 +120,7 @@
"compositePrimaryKeys": {
"Document_id_createdAt_pk": {
"name": "Document_id_createdAt_pk",
"columns": [
"id",
"createdAt"
]
"columns": ["id", "createdAt"]
}
},
"uniqueConstraints": {}
@ -184,12 +173,8 @@
"name": "Message_v2_chatId_Chat_id_fk",
"tableFrom": "Message_v2",
"tableTo": "Chat",
"columnsFrom": [
"chatId"
],
"columnsTo": [
"id"
],
"columnsFrom": ["chatId"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
}
@ -239,12 +224,8 @@
"name": "Message_chatId_Chat_id_fk",
"tableFrom": "Message",
"tableTo": "Chat",
"columnsFrom": [
"chatId"
],
"columnsTo": [
"id"
],
"columnsFrom": ["chatId"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
}
@ -282,12 +263,8 @@
"name": "Stream_chatId_Chat_id_fk",
"tableFrom": "Stream",
"tableTo": "Chat",
"columnsFrom": [
"chatId"
],
"columnsTo": [
"id"
],
"columnsFrom": ["chatId"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
}
@ -295,9 +272,7 @@
"compositePrimaryKeys": {
"Stream_id_pk": {
"name": "Stream_id_pk",
"columns": [
"id"
]
"columns": ["id"]
}
},
"uniqueConstraints": {}
@ -369,12 +344,8 @@
"name": "Suggestion_userId_User_id_fk",
"tableFrom": "Suggestion",
"tableTo": "User",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"columnsFrom": ["userId"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
},
@ -382,14 +353,8 @@
"name": "Suggestion_documentId_documentCreatedAt_Document_id_createdAt_fk",
"tableFrom": "Suggestion",
"tableTo": "Document",
"columnsFrom": [
"documentId",
"documentCreatedAt"
],
"columnsTo": [
"id",
"createdAt"
],
"columnsFrom": ["documentId", "documentCreatedAt"],
"columnsTo": ["id", "createdAt"],
"onDelete": "no action",
"onUpdate": "no action"
}
@ -397,9 +362,7 @@
"compositePrimaryKeys": {
"Suggestion_id_pk": {
"name": "Suggestion_id_pk",
"columns": [
"id"
]
"columns": ["id"]
}
},
"uniqueConstraints": {}
@ -462,12 +425,8 @@
"name": "Vote_v2_chatId_Chat_id_fk",
"tableFrom": "Vote_v2",
"tableTo": "Chat",
"columnsFrom": [
"chatId"
],
"columnsTo": [
"id"
],
"columnsFrom": ["chatId"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
},
@ -475,12 +434,8 @@
"name": "Vote_v2_messageId_Message_v2_id_fk",
"tableFrom": "Vote_v2",
"tableTo": "Message_v2",
"columnsFrom": [
"messageId"
],
"columnsTo": [
"id"
],
"columnsFrom": ["messageId"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
}
@ -488,10 +443,7 @@
"compositePrimaryKeys": {
"Vote_v2_chatId_messageId_pk": {
"name": "Vote_v2_chatId_messageId_pk",
"columns": [
"chatId",
"messageId"
]
"columns": ["chatId", "messageId"]
}
},
"uniqueConstraints": {}
@ -525,12 +477,8 @@
"name": "Vote_chatId_Chat_id_fk",
"tableFrom": "Vote",
"tableTo": "Chat",
"columnsFrom": [
"chatId"
],
"columnsTo": [
"id"
],
"columnsFrom": ["chatId"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
},
@ -538,12 +486,8 @@
"name": "Vote_messageId_Message_id_fk",
"tableFrom": "Vote",
"tableTo": "Message",
"columnsFrom": [
"messageId"
],
"columnsTo": [
"id"
],
"columnsFrom": ["messageId"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
}
@ -551,10 +495,7 @@
"compositePrimaryKeys": {
"Vote_chatId_messageId_pk": {
"name": "Vote_chatId_messageId_pk",
"columns": [
"chatId",
"messageId"
]
"columns": ["chatId", "messageId"]
}
},
"uniqueConstraints": {}
@ -568,4 +509,4 @@
"schemas": {},
"tables": {}
}
}
}

View file

@ -59,4 +59,4 @@
"breakpoints": true
}
]
}
}

View file

@ -1,4 +1,4 @@
import 'server-only';
import "server-only";
import {
and,
@ -11,29 +11,28 @@ import {
inArray,
lt,
type SQL,
} from 'drizzle-orm';
import { drizzle } from 'drizzle-orm/postgres-js';
import postgres from 'postgres';
} from "drizzle-orm";
import { drizzle } from "drizzle-orm/postgres-js";
import postgres from "postgres";
import type { ArtifactKind } from "@/components/artifact";
import type { VisibilityType } from "@/components/visibility-selector";
import { ChatSDKError } from "../errors";
import type { AppUsage } from "../usage";
import { generateUUID } from "../utils";
import {
user,
chat,
type User,
document,
type Suggestion,
suggestion,
message,
vote,
type DBMessage,
type Chat,
chat,
type DBMessage,
document,
message,
type Suggestion,
stream,
} from './schema';
import type { ArtifactKind } from '@/components/artifact';
import { generateUUID } from '../utils';
import { generateHashedPassword } from './utils';
import type { VisibilityType } from '@/components/visibility-selector';
import { ChatSDKError } from '../errors';
import type { AppUsage } from '../usage';
suggestion,
type User,
user,
vote,
} from "./schema";
import { generateHashedPassword } from "./utils";
// Optionally, if not using email/pass login, you can
// use the Drizzle adapter for Auth.js / NextAuth
@ -43,13 +42,13 @@ import type { AppUsage } from '../usage';
const client = postgres(process.env.POSTGRES_URL!);
const db = drizzle(client);
export async function getUser(email: string): Promise<Array<User>> {
export async function getUser(email: string): Promise<User[]> {
try {
return await db.select().from(user).where(eq(user.email, email));
} catch (error) {
} catch (_error) {
throw new ChatSDKError(
'bad_request:database',
'Failed to get user by email',
"bad_request:database",
"Failed to get user by email"
);
}
}
@ -59,8 +58,8 @@ export async function createUser(email: string, password: string) {
try {
return await db.insert(user).values({ email, password: hashedPassword });
} catch (error) {
throw new ChatSDKError('bad_request:database', 'Failed to create user');
} catch (_error) {
throw new ChatSDKError("bad_request:database", "Failed to create user");
}
}
@ -73,10 +72,10 @@ export async function createGuestUser() {
id: user.id,
email: user.email,
});
} catch (error) {
} catch (_error) {
throw new ChatSDKError(
'bad_request:database',
'Failed to create guest user',
"bad_request:database",
"Failed to create guest user"
);
}
}
@ -100,8 +99,8 @@ export async function saveChat({
title,
visibility,
});
} catch (error) {
throw new ChatSDKError('bad_request:database', 'Failed to save chat');
} catch (_error) {
throw new ChatSDKError("bad_request:database", "Failed to save chat");
}
}
@ -116,10 +115,10 @@ export async function deleteChatById({ id }: { id: string }) {
.where(eq(chat.id, id))
.returning();
return chatsDeleted;
} catch (error) {
} catch (_error) {
throw new ChatSDKError(
'bad_request:database',
'Failed to delete chat by id',
"bad_request:database",
"Failed to delete chat by id"
);
}
}
@ -145,12 +144,12 @@ export async function getChatsByUserId({
.where(
whereCondition
? and(whereCondition, eq(chat.userId, id))
: eq(chat.userId, id),
: eq(chat.userId, id)
)
.orderBy(desc(chat.createdAt))
.limit(extendedLimit);
let filteredChats: Array<Chat> = [];
let filteredChats: Chat[] = [];
if (startingAfter) {
const [selectedChat] = await db
@ -161,8 +160,8 @@ export async function getChatsByUserId({
if (!selectedChat) {
throw new ChatSDKError(
'not_found:database',
`Chat with id ${startingAfter} not found`,
"not_found:database",
`Chat with id ${startingAfter} not found`
);
}
@ -176,8 +175,8 @@ export async function getChatsByUserId({
if (!selectedChat) {
throw new ChatSDKError(
'not_found:database',
`Chat with id ${endingBefore} not found`,
"not_found:database",
`Chat with id ${endingBefore} not found`
);
}
@ -192,10 +191,10 @@ export async function getChatsByUserId({
chats: hasMore ? filteredChats.slice(0, limit) : filteredChats,
hasMore,
};
} catch (error) {
} catch (_error) {
throw new ChatSDKError(
'bad_request:database',
'Failed to get chats by user id',
"bad_request:database",
"Failed to get chats by user id"
);
}
}
@ -208,20 +207,16 @@ export async function getChatById({ id }: { id: string }) {
}
return selectedChat;
} catch (error) {
throw new ChatSDKError('bad_request:database', 'Failed to get chat by id');
} catch (_error) {
throw new ChatSDKError("bad_request:database", "Failed to get chat by id");
}
}
export async function saveMessages({
messages,
}: {
messages: Array<DBMessage>;
}) {
export async function saveMessages({ messages }: { messages: DBMessage[] }) {
try {
return await db.insert(message).values(messages);
} catch (error) {
throw new ChatSDKError('bad_request:database', 'Failed to save messages');
} catch (_error) {
throw new ChatSDKError("bad_request:database", "Failed to save messages");
}
}
@ -232,10 +227,10 @@ export async function getMessagesByChatId({ id }: { id: string }) {
.from(message)
.where(eq(message.chatId, id))
.orderBy(asc(message.createdAt));
} catch (error) {
} catch (_error) {
throw new ChatSDKError(
'bad_request:database',
'Failed to get messages by chat id',
"bad_request:database",
"Failed to get messages by chat id"
);
}
}
@ -247,7 +242,7 @@ export async function voteMessage({
}: {
chatId: string;
messageId: string;
type: 'up' | 'down';
type: "up" | "down";
}) {
try {
const [existingVote] = await db
@ -258,26 +253,26 @@ export async function voteMessage({
if (existingVote) {
return await db
.update(vote)
.set({ isUpvoted: type === 'up' })
.set({ isUpvoted: type === "up" })
.where(and(eq(vote.messageId, messageId), eq(vote.chatId, chatId)));
}
return await db.insert(vote).values({
chatId,
messageId,
isUpvoted: type === 'up',
isUpvoted: type === "up",
});
} catch (error) {
throw new ChatSDKError('bad_request:database', 'Failed to vote message');
} catch (_error) {
throw new ChatSDKError("bad_request:database", "Failed to vote message");
}
}
export async function getVotesByChatId({ id }: { id: string }) {
try {
return await db.select().from(vote).where(eq(vote.chatId, id));
} catch (error) {
} catch (_error) {
throw new ChatSDKError(
'bad_request:database',
'Failed to get votes by chat id',
"bad_request:database",
"Failed to get votes by chat id"
);
}
}
@ -307,8 +302,8 @@ export async function saveDocument({
createdAt: new Date(),
})
.returning();
} catch (error) {
throw new ChatSDKError('bad_request:database', 'Failed to save document');
} catch (_error) {
throw new ChatSDKError("bad_request:database", "Failed to save document");
}
}
@ -321,10 +316,10 @@ export async function getDocumentsById({ id }: { id: string }) {
.orderBy(asc(document.createdAt));
return documents;
} catch (error) {
} catch (_error) {
throw new ChatSDKError(
'bad_request:database',
'Failed to get documents by id',
"bad_request:database",
"Failed to get documents by id"
);
}
}
@ -338,10 +333,10 @@ export async function getDocumentById({ id }: { id: string }) {
.orderBy(desc(document.createdAt));
return selectedDocument;
} catch (error) {
} catch (_error) {
throw new ChatSDKError(
'bad_request:database',
'Failed to get document by id',
"bad_request:database",
"Failed to get document by id"
);
}
}
@ -359,18 +354,18 @@ export async function deleteDocumentsByIdAfterTimestamp({
.where(
and(
eq(suggestion.documentId, id),
gt(suggestion.documentCreatedAt, timestamp),
),
gt(suggestion.documentCreatedAt, timestamp)
)
);
return await db
.delete(document)
.where(and(eq(document.id, id), gt(document.createdAt, timestamp)))
.returning();
} catch (error) {
} catch (_error) {
throw new ChatSDKError(
'bad_request:database',
'Failed to delete documents by id after timestamp',
"bad_request:database",
"Failed to delete documents by id after timestamp"
);
}
}
@ -378,14 +373,14 @@ export async function deleteDocumentsByIdAfterTimestamp({
export async function saveSuggestions({
suggestions,
}: {
suggestions: Array<Suggestion>;
suggestions: Suggestion[];
}) {
try {
return await db.insert(suggestion).values(suggestions);
} catch (error) {
} catch (_error) {
throw new ChatSDKError(
'bad_request:database',
'Failed to save suggestions',
"bad_request:database",
"Failed to save suggestions"
);
}
}
@ -400,10 +395,10 @@ export async function getSuggestionsByDocumentId({
.select()
.from(suggestion)
.where(and(eq(suggestion.documentId, documentId)));
} catch (error) {
} catch (_error) {
throw new ChatSDKError(
'bad_request:database',
'Failed to get suggestions by document id',
"bad_request:database",
"Failed to get suggestions by document id"
);
}
}
@ -411,10 +406,10 @@ export async function getSuggestionsByDocumentId({
export async function getMessageById({ id }: { id: string }) {
try {
return await db.select().from(message).where(eq(message.id, id));
} catch (error) {
} catch (_error) {
throw new ChatSDKError(
'bad_request:database',
'Failed to get message by id',
"bad_request:database",
"Failed to get message by id"
);
}
}
@ -431,28 +426,30 @@ export async function deleteMessagesByChatIdAfterTimestamp({
.select({ id: message.id })
.from(message)
.where(
and(eq(message.chatId, chatId), gte(message.createdAt, timestamp)),
and(eq(message.chatId, chatId), gte(message.createdAt, timestamp))
);
const messageIds = messagesToDelete.map((message) => message.id);
const messageIds = messagesToDelete.map(
(currentMessage) => currentMessage.id
);
if (messageIds.length > 0) {
await db
.delete(vote)
.where(
and(eq(vote.chatId, chatId), inArray(vote.messageId, messageIds)),
and(eq(vote.chatId, chatId), inArray(vote.messageId, messageIds))
);
return await db
.delete(message)
.where(
and(eq(message.chatId, chatId), inArray(message.id, messageIds)),
and(eq(message.chatId, chatId), inArray(message.id, messageIds))
);
}
} catch (error) {
} catch (_error) {
throw new ChatSDKError(
'bad_request:database',
'Failed to delete messages by chat id after timestamp',
"bad_request:database",
"Failed to delete messages by chat id after timestamp"
);
}
}
@ -462,14 +459,14 @@ export async function updateChatVisiblityById({
visibility,
}: {
chatId: string;
visibility: 'private' | 'public';
visibility: "private" | "public";
}) {
try {
return await db.update(chat).set({ visibility }).where(eq(chat.id, chatId));
} catch (error) {
} catch (_error) {
throw new ChatSDKError(
'bad_request:database',
'Failed to update chat visibility by id',
"bad_request:database",
"Failed to update chat visibility by id"
);
}
}
@ -488,7 +485,7 @@ export async function updateChatLastContextById({
.set({ lastContext: context })
.where(eq(chat.id, chatId));
} catch (error) {
console.warn('Failed to update lastContext for chat', chatId, error);
console.warn("Failed to update lastContext for chat", chatId, error);
return;
}
}
@ -502,7 +499,7 @@ export async function getMessageCountByUserId({
}) {
try {
const twentyFourHoursAgo = new Date(
Date.now() - differenceInHours * 60 * 60 * 1000,
Date.now() - differenceInHours * 60 * 60 * 1000
);
const [stats] = await db
@ -513,16 +510,16 @@ export async function getMessageCountByUserId({
and(
eq(chat.userId, id),
gte(message.createdAt, twentyFourHoursAgo),
eq(message.role, 'user'),
),
eq(message.role, "user")
)
)
.execute();
return stats?.count ?? 0;
} catch (error) {
} catch (_error) {
throw new ChatSDKError(
'bad_request:database',
'Failed to get message count by user id',
"bad_request:database",
"Failed to get message count by user id"
);
}
}
@ -538,10 +535,10 @@ export async function createStreamId({
await db
.insert(stream)
.values({ id: streamId, chatId, createdAt: new Date() });
} catch (error) {
} catch (_error) {
throw new ChatSDKError(
'bad_request:database',
'Failed to create stream id',
"bad_request:database",
"Failed to create stream id"
);
}
}
@ -556,10 +553,10 @@ export async function getStreamIdsByChatId({ chatId }: { chatId: string }) {
.execute();
return streamIds.map(({ id }) => id);
} catch (error) {
} catch (_error) {
throw new ChatSDKError(
'bad_request:database',
'Failed to get stream ids by chat id',
"bad_request:database",
"Failed to get stream ids by chat id"
);
}
}

View file

@ -1,64 +1,64 @@
import type { InferSelectModel } from 'drizzle-orm';
import type { InferSelectModel } from "drizzle-orm";
import {
pgTable,
varchar,
timestamp,
boolean,
foreignKey,
json,
jsonb,
uuid,
text,
pgTable,
primaryKey,
foreignKey,
boolean,
} from 'drizzle-orm/pg-core';
import type { AppUsage } from '../usage';
text,
timestamp,
uuid,
varchar,
} from "drizzle-orm/pg-core";
import type { AppUsage } from "../usage";
export const user = pgTable('User', {
id: uuid('id').primaryKey().notNull().defaultRandom(),
email: varchar('email', { length: 64 }).notNull(),
password: varchar('password', { length: 64 }),
export const user = pgTable("User", {
id: uuid("id").primaryKey().notNull().defaultRandom(),
email: varchar("email", { length: 64 }).notNull(),
password: varchar("password", { length: 64 }),
});
export type User = InferSelectModel<typeof user>;
export const chat = pgTable('Chat', {
id: uuid('id').primaryKey().notNull().defaultRandom(),
createdAt: timestamp('createdAt').notNull(),
title: text('title').notNull(),
userId: uuid('userId')
export const chat = pgTable("Chat", {
id: uuid("id").primaryKey().notNull().defaultRandom(),
createdAt: timestamp("createdAt").notNull(),
title: text("title").notNull(),
userId: uuid("userId")
.notNull()
.references(() => user.id),
visibility: varchar('visibility', { enum: ['public', 'private'] })
visibility: varchar("visibility", { enum: ["public", "private"] })
.notNull()
.default('private'),
lastContext: jsonb('lastContext').$type<AppUsage | null>(),
.default("private"),
lastContext: jsonb("lastContext").$type<AppUsage | null>(),
});
export type Chat = InferSelectModel<typeof chat>;
// DEPRECATED: The following schema is deprecated and will be removed in the future.
// Read the migration guide at https://chat-sdk.dev/docs/migration-guides/message-parts
export const messageDeprecated = pgTable('Message', {
id: uuid('id').primaryKey().notNull().defaultRandom(),
chatId: uuid('chatId')
export const messageDeprecated = pgTable("Message", {
id: uuid("id").primaryKey().notNull().defaultRandom(),
chatId: uuid("chatId")
.notNull()
.references(() => chat.id),
role: varchar('role').notNull(),
content: json('content').notNull(),
createdAt: timestamp('createdAt').notNull(),
role: varchar("role").notNull(),
content: json("content").notNull(),
createdAt: timestamp("createdAt").notNull(),
});
export type MessageDeprecated = InferSelectModel<typeof messageDeprecated>;
export const message = pgTable('Message_v2', {
id: uuid('id').primaryKey().notNull().defaultRandom(),
chatId: uuid('chatId')
export const message = pgTable("Message_v2", {
id: uuid("id").primaryKey().notNull().defaultRandom(),
chatId: uuid("chatId")
.notNull()
.references(() => chat.id),
role: varchar('role').notNull(),
parts: json('parts').notNull(),
attachments: json('attachments').notNull(),
createdAt: timestamp('createdAt').notNull(),
role: varchar("role").notNull(),
parts: json("parts").notNull(),
attachments: json("attachments").notNull(),
createdAt: timestamp("createdAt").notNull(),
});
export type DBMessage = InferSelectModel<typeof message>;
@ -66,56 +66,56 @@ export type DBMessage = InferSelectModel<typeof message>;
// DEPRECATED: The following schema is deprecated and will be removed in the future.
// Read the migration guide at https://chat-sdk.dev/docs/migration-guides/message-parts
export const voteDeprecated = pgTable(
'Vote',
"Vote",
{
chatId: uuid('chatId')
chatId: uuid("chatId")
.notNull()
.references(() => chat.id),
messageId: uuid('messageId')
messageId: uuid("messageId")
.notNull()
.references(() => messageDeprecated.id),
isUpvoted: boolean('isUpvoted').notNull(),
isUpvoted: boolean("isUpvoted").notNull(),
},
(table) => {
return {
pk: primaryKey({ columns: [table.chatId, table.messageId] }),
};
},
}
);
export type VoteDeprecated = InferSelectModel<typeof voteDeprecated>;
export const vote = pgTable(
'Vote_v2',
"Vote_v2",
{
chatId: uuid('chatId')
chatId: uuid("chatId")
.notNull()
.references(() => chat.id),
messageId: uuid('messageId')
messageId: uuid("messageId")
.notNull()
.references(() => message.id),
isUpvoted: boolean('isUpvoted').notNull(),
isUpvoted: boolean("isUpvoted").notNull(),
},
(table) => {
return {
pk: primaryKey({ columns: [table.chatId, table.messageId] }),
};
},
}
);
export type Vote = InferSelectModel<typeof vote>;
export const document = pgTable(
'Document',
"Document",
{
id: uuid('id').notNull().defaultRandom(),
createdAt: timestamp('createdAt').notNull(),
title: text('title').notNull(),
content: text('content'),
kind: varchar('text', { enum: ['text', 'code', 'image', 'sheet'] })
id: uuid("id").notNull().defaultRandom(),
createdAt: timestamp("createdAt").notNull(),
title: text("title").notNull(),
content: text("content"),
kind: varchar("text", { enum: ["text", "code", "image", "sheet"] })
.notNull()
.default('text'),
userId: uuid('userId')
.default("text"),
userId: uuid("userId")
.notNull()
.references(() => user.id),
},
@ -123,25 +123,25 @@ export const document = pgTable(
return {
pk: primaryKey({ columns: [table.id, table.createdAt] }),
};
},
}
);
export type Document = InferSelectModel<typeof document>;
export const suggestion = pgTable(
'Suggestion',
"Suggestion",
{
id: uuid('id').notNull().defaultRandom(),
documentId: uuid('documentId').notNull(),
documentCreatedAt: timestamp('documentCreatedAt').notNull(),
originalText: text('originalText').notNull(),
suggestedText: text('suggestedText').notNull(),
description: text('description'),
isResolved: boolean('isResolved').notNull().default(false),
userId: uuid('userId')
id: uuid("id").notNull().defaultRandom(),
documentId: uuid("documentId").notNull(),
documentCreatedAt: timestamp("documentCreatedAt").notNull(),
originalText: text("originalText").notNull(),
suggestedText: text("suggestedText").notNull(),
description: text("description"),
isResolved: boolean("isResolved").notNull().default(false),
userId: uuid("userId")
.notNull()
.references(() => user.id),
createdAt: timestamp('createdAt').notNull(),
createdAt: timestamp("createdAt").notNull(),
},
(table) => ({
pk: primaryKey({ columns: [table.id] }),
@ -149,17 +149,17 @@ export const suggestion = pgTable(
columns: [table.documentId, table.documentCreatedAt],
foreignColumns: [document.id, document.createdAt],
}),
}),
})
);
export type Suggestion = InferSelectModel<typeof suggestion>;
export const stream = pgTable(
'Stream',
"Stream",
{
id: uuid('id').notNull().defaultRandom(),
chatId: uuid('chatId').notNull(),
createdAt: timestamp('createdAt').notNull(),
id: uuid("id").notNull().defaultRandom(),
chatId: uuid("chatId").notNull(),
createdAt: timestamp("createdAt").notNull(),
},
(table) => ({
pk: primaryKey({ columns: [table.id] }),
@ -167,7 +167,7 @@ export const stream = pgTable(
columns: [table.chatId],
foreignColumns: [chat.id],
}),
}),
})
);
export type Stream = InferSelectModel<typeof stream>;

View file

@ -1,5 +1,5 @@
import { generateId } from 'ai';
import { genSaltSync, hashSync } from 'bcrypt-ts';
import { generateId } from "ai";
import { genSaltSync, hashSync } from "bcrypt-ts";
export function generateHashedPassword(password: string) {
const salt = genSaltSync(10);