68 lines
2.2 KiB
TypeScript
68 lines
2.2 KiB
TypeScript
import { integer, sqliteTable, text, unique } from "drizzle-orm/sqlite-core";
|
|
|
|
export const felicaCardLookup = sqliteTable(
|
|
"aimedb_felica_card_lookup",
|
|
{
|
|
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
idm: text("idm", { length: 16 }).notNull(),
|
|
accessCode: text("access_code", { length: 20 }).notNull(),
|
|
},
|
|
(t) => ({
|
|
unqIdm: unique().on(t.idm),
|
|
unqAc: unique().on(t.accessCode),
|
|
})
|
|
);
|
|
|
|
export type FelicaCardLookup = typeof felicaMobileLookup.$inferSelect;
|
|
export type NewFelicaCardLookup = typeof felicaMobileLookup.$inferSelect;
|
|
|
|
export const felicaMobileLookup = sqliteTable(
|
|
"aimedb_felica_mobile_lookup",
|
|
{
|
|
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
idm: text("idm", { length: 16 }).notNull(),
|
|
accessCode: text("access_code", { length: 20 }).notNull(),
|
|
},
|
|
(t) => ({
|
|
unqIdm: unique().on(t.idm),
|
|
unqAc: unique().on(t.accessCode),
|
|
})
|
|
);
|
|
|
|
export type FelicaMobileLookup = typeof felicaMobileLookup.$inferSelect;
|
|
export type NewFelicaMobileLookup = typeof felicaMobileLookup.$inferInsert;
|
|
|
|
export const user = sqliteTable("aimedb_user", {
|
|
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
createdDate: integer("created_date", { mode: "timestamp" })
|
|
.notNull()
|
|
.$default(() => new Date()),
|
|
lastLoginDate: integer("last_login_date", { mode: "timestamp" })
|
|
.notNull()
|
|
.$default(() => new Date()),
|
|
suspendExpirationDate: integer("suspend_expiration_date", { mode: "timestamp" }),
|
|
});
|
|
|
|
export type AimeUser = typeof user.$inferSelect;
|
|
export type NewAimeUser = typeof user.$inferInsert;
|
|
|
|
export const card = sqliteTable(
|
|
"aimedb_card",
|
|
{
|
|
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
userId: integer("user_id").references(() => user.id),
|
|
accessCode: text("access_code", { length: 20 }).notNull(),
|
|
createdDate: integer("created_date", { mode: "timestamp" })
|
|
.notNull()
|
|
.$default(() => new Date()),
|
|
lastLoginDate: integer("last_login_date", { mode: "timestamp" })
|
|
.notNull()
|
|
.$default(() => new Date()),
|
|
isLocked: integer("is_locked", { mode: "boolean" }).default(false).notNull(),
|
|
isBanned: integer("is_banned", { mode: "boolean" }).default(false).notNull(),
|
|
},
|
|
(t) => ({
|
|
unqAc: unique().on(t.accessCode),
|
|
})
|
|
);
|