mirror of
https://git.sr.ht/~roxwize/mipilin
synced 2025-05-10 23:33:07 +00:00
this is the initial commit for my AWESOME website
Signed-off-by: roxwize <rae@roxwize.xyz>
This commit is contained in:
commit
e3c09d7f0d
42 changed files with 5710 additions and 0 deletions
54
db/schema.ts
Normal file
54
db/schema.ts
Normal file
|
@ -0,0 +1,54 @@
|
|||
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] })
|
||||
};
|
||||
}
|
||||
);
|
Loading…
Add table
Add a link
Reference in a new issue