feat(db): hand-author drizzle schema for users, users_currency, bans, website_settings
This commit is contained in:
1 parent
0966aa7dda
commit
5369f99b07
5 files changed
+68
No files matched your search
@@ -0,0 +1,16 @@
|
||||
import { mysqlTable, int, varchar, mysqlEnum } from "drizzle-orm/mysql-core";
|
||||
|
||||
export const bans = mysqlTable("bans", {
|
||||
id: int("id").autoincrement().primaryKey(),
|
||||
userId: int("user_id").notNull(),
|
||||
ip: varchar("ip", { length: 50 }).notNull().default(""),
|
||||
machineId: varchar("machine_id", { length: 255 }).notNull().default(""),
|
||||
userStaffId: int("user_staff_id").notNull(),
|
||||
timestamp: int("timestamp").notNull(),
|
||||
banExpire: int("ban_expire").notNull().default(0),
|
||||
banReason: varchar("ban_reason", { length: 200 }).notNull().default(""),
|
||||
type: mysqlEnum("type", ["account", "ip", "machine", "super"])
|
||||
.notNull()
|
||||
.default("account"),
|
||||
cfhTopic: int("cfh_topic").notNull().default(-1),
|
||||
});
|
||||
@@ -0,0 +1,4 @@
|
||||
export { users } from "./users.js";
|
||||
export { usersCurrency } from "./users-currency.js";
|
||||
export { bans } from "./bans.js";
|
||||
export { websiteSettings } from "./website-settings.js";
|
||||
@@ -0,0 +1,13 @@
|
||||
import { mysqlTable, int, primaryKey } from "drizzle-orm/mysql-core";
|
||||
|
||||
// MyISAM table with a composite primary key and no surrogate id column.
|
||||
// This is the canonical test of the introspect-only / composite-key design.
|
||||
export const usersCurrency = mysqlTable(
|
||||
"users_currency",
|
||||
{
|
||||
userId: int("user_id").notNull(),
|
||||
type: int("type").notNull(),
|
||||
amount: int("amount").notNull().default(0),
|
||||
},
|
||||
(t) => [primaryKey({ columns: [t.userId, t.type] })],
|
||||
);
|
||||
@@ -0,0 +1,25 @@
|
||||
import { mysqlTable, int, varchar, mysqlEnum } from "drizzle-orm/mysql-core";
|
||||
|
||||
// Subset of the real `users` table — the columns the web tier needs first.
|
||||
// The complete column set will be regenerated via `db:pull` against the live DB.
|
||||
export const users = mysqlTable("users", {
|
||||
id: int("id").autoincrement().primaryKey(),
|
||||
username: varchar("username", { length: 25 }).notNull(),
|
||||
realName: varchar("real_name", { length: 25 }).notNull(),
|
||||
password: varchar("password", { length: 64 }).notNull(),
|
||||
mail: varchar("mail", { length: 500 }),
|
||||
mailVerified: mysqlEnum("mail_verified", ["0", "1"]).notNull().default("0"),
|
||||
accountCreated: int("account_created").notNull(),
|
||||
lastLogin: int("last_login").notNull().default(0),
|
||||
motto: varchar("motto", { length: 127 }).notNull().default(""),
|
||||
look: varchar("look", { length: 256 }).notNull(),
|
||||
gender: mysqlEnum("gender", ["M", "F"]).notNull().default("M"),
|
||||
rank: int("rank").notNull().default(1),
|
||||
credits: int("credits").notNull().default(2500),
|
||||
pixels: int("pixels").notNull().default(500),
|
||||
points: int("points").notNull().default(10),
|
||||
online: mysqlEnum("online", ["0", "1", "2"]).notNull().default("0"),
|
||||
authTicket: varchar("auth_ticket", { length: 256 }).notNull().default(""),
|
||||
ipRegister: varchar("ip_register", { length: 45 }).notNull(),
|
||||
ipCurrent: varchar("ip_current", { length: 45 }).notNull(),
|
||||
});
|
||||
@@ -0,0 +1,10 @@
|
||||
import { mysqlTable, bigint, varchar, text } from "drizzle-orm/mysql-core";
|
||||
|
||||
// CMS-owned table (created by Laravel migration, not in default.sql).
|
||||
// `value` was widened from varchar(255) to TEXT by a later migration.
|
||||
export const websiteSettings = mysqlTable("website_settings", {
|
||||
id: bigint("id", { mode: "number", unsigned: true }).autoincrement().primaryKey(),
|
||||
key: varchar("key", { length: 255 }).notNull(),
|
||||
value: text("value").notNull(),
|
||||
comment: varchar("comment", { length: 255 }).notNull(),
|
||||
});
|
||||
Reference in new issue
Block a user