Revert "Upgrade linter and formatter to Ultracite" (#1226)

This commit is contained in:
josh 2025-09-21 12:03:29 +01:00 committed by GitHub
parent 0e320b391d
commit 1aff7d9868
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
177 changed files with 8334 additions and 6943 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,8 +40,12 @@
"name": "Chat_userId_User_id_fk",
"tableFrom": "Chat",
"tableTo": "User",
"columnsFrom": ["userId"],
"columnsTo": ["id"],
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
@ -87,4 +91,4 @@
"schemas": {},
"tables": {}
}
}
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -53,8 +53,12 @@
"name": "Chat_userId_User_id_fk",
"tableFrom": "Chat",
"tableTo": "User",
"columnsFrom": ["userId"],
"columnsTo": ["id"],
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
@ -111,8 +115,12 @@
"name": "Document_userId_User_id_fk",
"tableFrom": "Document",
"tableTo": "User",
"columnsFrom": ["userId"],
"columnsTo": ["id"],
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
@ -120,7 +128,10 @@
"compositePrimaryKeys": {
"Document_id_createdAt_pk": {
"name": "Document_id_createdAt_pk",
"columns": ["id", "createdAt"]
"columns": [
"id",
"createdAt"
]
}
},
"uniqueConstraints": {}
@ -173,8 +184,12 @@
"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"
}
@ -224,8 +239,12 @@
"name": "Message_chatId_Chat_id_fk",
"tableFrom": "Message",
"tableTo": "Chat",
"columnsFrom": ["chatId"],
"columnsTo": ["id"],
"columnsFrom": [
"chatId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
@ -263,8 +282,12 @@
"name": "Stream_chatId_Chat_id_fk",
"tableFrom": "Stream",
"tableTo": "Chat",
"columnsFrom": ["chatId"],
"columnsTo": ["id"],
"columnsFrom": [
"chatId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
@ -272,7 +295,9 @@
"compositePrimaryKeys": {
"Stream_id_pk": {
"name": "Stream_id_pk",
"columns": ["id"]
"columns": [
"id"
]
}
},
"uniqueConstraints": {}
@ -344,8 +369,12 @@
"name": "Suggestion_userId_User_id_fk",
"tableFrom": "Suggestion",
"tableTo": "User",
"columnsFrom": ["userId"],
"columnsTo": ["id"],
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
@ -353,8 +382,14 @@
"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"
}
@ -362,7 +397,9 @@
"compositePrimaryKeys": {
"Suggestion_id_pk": {
"name": "Suggestion_id_pk",
"columns": ["id"]
"columns": [
"id"
]
}
},
"uniqueConstraints": {}
@ -425,8 +462,12 @@
"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"
},
@ -434,8 +475,12 @@
"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"
}
@ -443,7 +488,10 @@
"compositePrimaryKeys": {
"Vote_v2_chatId_messageId_pk": {
"name": "Vote_v2_chatId_messageId_pk",
"columns": ["chatId", "messageId"]
"columns": [
"chatId",
"messageId"
]
}
},
"uniqueConstraints": {}
@ -477,8 +525,12 @@
"name": "Vote_chatId_Chat_id_fk",
"tableFrom": "Vote",
"tableTo": "Chat",
"columnsFrom": ["chatId"],
"columnsTo": ["id"],
"columnsFrom": [
"chatId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
@ -486,8 +538,12 @@
"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,7 +551,10 @@
"compositePrimaryKeys": {
"Vote_chatId_messageId_pk": {
"name": "Vote_chatId_messageId_pk",
"columns": ["chatId", "messageId"]
"columns": [
"chatId",
"messageId"
]
}
},
"uniqueConstraints": {}
@ -509,4 +568,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,28 +11,29 @@ import {
inArray,
lt,
type SQL,
} 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";
} from 'drizzle-orm';
import { drizzle } from 'drizzle-orm/postgres-js';
import postgres from 'postgres';
import {
type Chat,
chat,
type DBMessage,
document,
message,
type Suggestion,
stream,
suggestion,
type User,
user,
chat,
type User,
document,
type Suggestion,
suggestion,
message,
vote,
} from "./schema";
import { generateHashedPassword } from "./utils";
type DBMessage,
type Chat,
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';
// Optionally, if not using email/pass login, you can
// use the Drizzle adapter for Auth.js / NextAuth
@ -42,13 +43,13 @@ import { generateHashedPassword } from "./utils";
const client = postgres(process.env.POSTGRES_URL!);
const db = drizzle(client);
export async function getUser(email: string): Promise<User[]> {
export async function getUser(email: string): Promise<Array<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',
);
}
}
@ -58,8 +59,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');
}
}
@ -72,10 +73,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',
);
}
}
@ -99,8 +100,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');
}
}
@ -115,10 +116,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',
);
}
}
@ -144,12 +145,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: Chat[] = [];
let filteredChats: Array<Chat> = [];
if (startingAfter) {
const [selectedChat] = await db
@ -160,8 +161,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`,
);
}
@ -175,8 +176,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`,
);
}
@ -191,10 +192,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',
);
}
}
@ -207,16 +208,20 @@ 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: DBMessage[] }) {
export async function saveMessages({
messages,
}: {
messages: Array<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');
}
}
@ -227,10 +232,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',
);
}
}
@ -242,7 +247,7 @@ export async function voteMessage({
}: {
chatId: string;
messageId: string;
type: "up" | "down";
type: 'up' | 'down';
}) {
try {
const [existingVote] = await db
@ -253,26 +258,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',
);
}
}
@ -302,8 +307,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');
}
}
@ -316,10 +321,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',
);
}
}
@ -333,10 +338,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',
);
}
}
@ -354,18 +359,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',
);
}
}
@ -373,14 +378,14 @@ export async function deleteDocumentsByIdAfterTimestamp({
export async function saveSuggestions({
suggestions,
}: {
suggestions: Suggestion[];
suggestions: Array<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',
);
}
}
@ -395,10 +400,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',
);
}
}
@ -406,10 +411,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',
);
}
}
@ -426,30 +431,28 @@ 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(
(currentMessage) => currentMessage.id
);
const messageIds = messagesToDelete.map((message) => message.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',
);
}
}
@ -459,14 +462,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',
);
}
}
@ -485,7 +488,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;
}
}
@ -499,7 +502,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
@ -510,16 +513,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',
);
}
}
@ -535,10 +538,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',
);
}
}
@ -553,10 +556,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 {
boolean,
foreignKey,
pgTable,
varchar,
timestamp,
json,
jsonb,
pgTable,
primaryKey,
text,
timestamp,
uuid,
varchar,
} from "drizzle-orm/pg-core";
import type { AppUsage } from "../usage";
text,
primaryKey,
foreignKey,
boolean,
} 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);