This commit is contained in:
yuanhau 2025-06-04 22:38:17 +08:00
parent 8032c3faae
commit feb679c3ef

View file

@ -1,6 +1,8 @@
import sql from "~/server/components/postgres"; import sql from "~/server/components/postgres";
const createSources = await sql``;
const createUsers = await sql` export default defineEventHandler(async (event) => {
const createUsers = await sql`
create table if not exists users ( create table if not exists users (
uuid text primary key, uuid text primary key,
created_at timestamptz default current_timestamp, created_at timestamptz default current_timestamp,
@ -12,7 +14,7 @@ const createUsers = await sql`
); );
`; `;
const usersList = await sql` const usersList = await sql`
create table if not exists usertokens ( create table if not exists usertokens (
token text not null primary key, token text not null primary key,
created_at timestamptz default current_timestamp, created_at timestamptz default current_timestamp,
@ -23,7 +25,7 @@ const usersList = await sql`
) )
`; `;
const createUserAiChatHistory = await sql` const createUserAiChatHistory = await sql`
CREATE TABLE IF NOT EXISTS chat_history ( CREATE TABLE IF NOT EXISTS chat_history (
id SERIAL PRIMARY KEY, id SERIAL PRIMARY KEY,
uuid VARCHAR(255) NOT NULL, uuid VARCHAR(255) NOT NULL,
@ -32,9 +34,6 @@ CREATE TABLE IF NOT EXISTS chat_history (
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)`; )`;
const createSources = await sql``;
export default defineEventHandler(async (event) => {
return { return {
createUsers: createUsers, createUsers: createUsers,
usersList: usersList, usersList: usersList,