mirror of
https://github.com/hpware/news-analyze.git
synced 2025-06-23 13:04:23 +00:00
Update createDatabase scripts & get sendUserInfo endpoint & when
creating an account it will also create a array in user_other_data.
This commit is contained in:
parent
a4a522974a
commit
3a85eda19a
5 changed files with 84 additions and 33 deletions
|
@ -1,41 +1,61 @@
|
|||
import sql from "~/server/components/postgres";
|
||||
export default defineEventHandler(async (event) => {
|
||||
const createUsers = await sql`
|
||||
create table if not exists users (
|
||||
uuid text primary key,
|
||||
created_at timestamptz default current_timestamp,
|
||||
username text not null unique,
|
||||
avatarurl text,
|
||||
firstname text,
|
||||
passwordhash text not null,
|
||||
email text
|
||||
);
|
||||
`;
|
||||
create table if not exists users (
|
||||
uuid text primary key,
|
||||
created_at timestamptz default current_timestamp,
|
||||
username text not null unique,
|
||||
avatarurl text,
|
||||
firstname text,
|
||||
passwordhash text not null,
|
||||
email text
|
||||
);
|
||||
`;
|
||||
|
||||
const usersList = await sql`
|
||||
create table if not exists usertokens (
|
||||
token text not null primary key,
|
||||
created_at timestamptz default current_timestamp,
|
||||
username text not null,
|
||||
email text,
|
||||
avatarurl text,
|
||||
firstname text
|
||||
)
|
||||
`;
|
||||
create table if not exists usertokens (
|
||||
token text not null primary key,
|
||||
created_at timestamptz default current_timestamp,
|
||||
username text not null,
|
||||
email text,
|
||||
avatarurl text,
|
||||
firstname text
|
||||
)
|
||||
`;
|
||||
|
||||
const createUserAiChatHistory = await sql`
|
||||
CREATE TABLE IF NOT EXISTS chat_history (
|
||||
id SERIAL PRIMARY KEY,
|
||||
uuid VARCHAR(255) NOT NULL,
|
||||
role VARCHAR(50) NOT NULL,
|
||||
content TEXT NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
)`;
|
||||
const createSources = await sql``;
|
||||
CREATE TABLE IF NOT EXISTS chat_history (
|
||||
id SERIAL PRIMARY KEY,
|
||||
uuid VARCHAR(255) NOT NULL,
|
||||
role VARCHAR(50) NOT NULL,
|
||||
content TEXT NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
)`;
|
||||
|
||||
const createUserOtherData = await sql`
|
||||
create table if not exists user_other_data (
|
||||
user_id text primary key ,
|
||||
user text not null unique,
|
||||
groq_api_key text,
|
||||
starred_news JSON not null,
|
||||
translate_provider text,
|
||||
translate_enabled boolean not null,
|
||||
remove_translate_popup boolean not null
|
||||
)`;
|
||||
|
||||
const createSources = await sql`
|
||||
create table if not exists lt_news_org (
|
||||
news_id text primary key,
|
||||
name text not null,
|
||||
description text
|
||||
)
|
||||
`;
|
||||
|
||||
return {
|
||||
createUsers: createUsers,
|
||||
usersList: usersList,
|
||||
createUserAiChatHistory: createUserAiChatHistory,
|
||||
createSources: createSources,
|
||||
createUserOtherData: createUserOtherData,
|
||||
};
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue