add group, server and friends to db
This commit is contained in:
parent
91284c242a
commit
37ae49b66e
6 changed files with 426 additions and 8 deletions
|
|
@ -2,20 +2,36 @@ import { sqliteTable, integer, text } from 'drizzle-orm/sqlite-core';
|
|||
|
||||
export const user = sqliteTable('user', {
|
||||
id: text('id').primaryKey(),
|
||||
age: integer('age'),
|
||||
username: text('username').notNull().unique(),
|
||||
email: text('email').notNull().unique(),
|
||||
passwordHash: text('password_hash').notNull()
|
||||
passwordHash: text('password_hash').notNull(),
|
||||
friends: text('friends', { mode: "json"}).default([]).notNull(),
|
||||
});
|
||||
|
||||
export const session = sqliteTable('session', {
|
||||
id: text('id').primaryKey(),
|
||||
userId: text('user_id')
|
||||
.notNull()
|
||||
.references(() => user.id),
|
||||
expiresAt: integer('expires_at', { mode: 'timestamp' }).notNull()
|
||||
id: text('id').primaryKey(),
|
||||
userId: text('user_id')
|
||||
.notNull()
|
||||
.references(() => user.id),
|
||||
expiresAt: integer('expires_at', { mode: 'timestamp' }).notNull()
|
||||
});
|
||||
|
||||
export type Session = typeof session.$inferSelect;
|
||||
export const server = sqliteTable("server", {
|
||||
id: text('id').primaryKey(),
|
||||
name: text('name').notNull(),
|
||||
owner: text('owner').notNull().references(() => user.id),
|
||||
members: text('members', { mode: "json"}).default([]).notNull(),
|
||||
channels: text('channels', { mode: "json"}).default([]).notNull(),
|
||||
})
|
||||
|
||||
export const group = sqliteTable("group", {
|
||||
id: text('id').primaryKey(),
|
||||
name: text('name').notNull(),
|
||||
owner: text('owner').notNull().references(() => user.id),
|
||||
members: text('members', { mode: "json"}).default([]).notNull(),
|
||||
})
|
||||
|
||||
export type Session = typeof session.$inferSelect;
|
||||
export type User = typeof user.$inferSelect;
|
||||
export type Group = typeof group.$inferSelect;
|
||||
export type Server = typeof server.$inferSelect;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue