1
0
Fork 0
mirror of https://git.sr.ht/~roxwize/mipilin synced 2025-01-31 02:53:36 +00:00
mipilin/db/schema.ts
roxwize e3c09d7f0d
this is the initial commit for my AWESOME website
Signed-off-by: roxwize <rae@roxwize.xyz>
2024-11-13 22:51:08 -05:00

54 lines
1.5 KiB
TypeScript

import {
boolean,
integer,
pgTable,
primaryKey,
timestamp,
varchar
} from "drizzle-orm/pg-core";
export const users = pgTable("users", {
id: integer().primaryKey().generatedAlwaysAsIdentity(),
email: varchar().unique().notNull(), //! make this required on signup
name: varchar({ length: 26 }).unique().notNull(),
pass: varchar({ length: 255 }).notNull(),
registered: timestamp().notNull(),
moderator: boolean().default(false).notNull(),
banned: boolean().default(false).notNull() //! Not actually functional, banned users can still login
});
export const updates = pgTable("updates", {
id: integer().primaryKey().generatedAlwaysAsIdentity(),
user: integer()
.references(() => users.id, { onDelete: "cascade" })
.notNull(),
mood: integer().default(0).notNull(),
description: varchar({ length: 512 }).default("").notNull(),
date: timestamp().notNull()
});
export const profiles = pgTable("profiles", {
user: integer()
.references(() => users.id, { onDelete: "cascade" })
.primaryKey()
.notNull(),
bio: varchar({ length: 1024 }).default("").notNull(),
website: varchar().default("").notNull()
});
export const follows = pgTable(
"follows",
{
userId: integer("user_id").references(() => users.id, {
onDelete: "cascade"
}),
followerId: integer("follower_id").references(() => users.id, {
onDelete: "cascade"
})
},
(table) => {
return {
pk: primaryKey({ columns: [table.userId, table.followerId] })
};
}
);