refactor: improve type definitions and enhance state management in profile and daily components
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { integer, sqliteTable, text, real, unique } from 'drizzle-orm/sqlite-core';
|
||||
import { user } from './auth.schema';
|
||||
import type { InferSelectModel } from 'drizzle-orm';
|
||||
|
||||
// Define devil fruit types
|
||||
export type DevilFruitType = 'Paramecia' | 'Zoan' | 'Logia' | 'Smile' | 'Unknown';
|
||||
@@ -23,6 +24,8 @@ export const arc = sqliteTable('arc', {
|
||||
url: text('url')
|
||||
});
|
||||
|
||||
export type Arc = InferSelectModel<typeof arc>;
|
||||
|
||||
// Define the devil fruit table schema
|
||||
export const devilFruit = sqliteTable('devil_fruit', {
|
||||
id: text('id').primaryKey(),
|
||||
@@ -31,6 +34,8 @@ export const devilFruit = sqliteTable('devil_fruit', {
|
||||
url: text('url')
|
||||
});
|
||||
|
||||
export type DevilFruit = InferSelectModel<typeof devilFruit>;
|
||||
|
||||
// Define the character table schema
|
||||
export const character = sqliteTable('character', {
|
||||
id: text('id').primaryKey(),
|
||||
@@ -58,6 +63,8 @@ export const character = sqliteTable('character', {
|
||||
isInDailyMode: integer('is_in_daily_mode', { mode: 'boolean' }).default(false)
|
||||
});
|
||||
|
||||
export type Character = InferSelectModel<typeof character>;
|
||||
|
||||
// Define the character override table schema
|
||||
export const characterOverride = sqliteTable('character_override', {
|
||||
characterId: text('character_id').primaryKey().references(() => character.id, { onDelete: 'cascade' }),
|
||||
@@ -82,6 +89,8 @@ export const characterOverride = sqliteTable('character_override', {
|
||||
notes: text('notes')
|
||||
});
|
||||
|
||||
export type CharacterOverride = InferSelectModel<typeof characterOverride>;
|
||||
|
||||
// Define the character scrape validation table schema
|
||||
export const characterScrapeValidation = sqliteTable('character_scrape_validation', {
|
||||
id: text('id').primaryKey(),
|
||||
@@ -108,6 +117,8 @@ export const characterScrapeValidation = sqliteTable('character_scrape_validatio
|
||||
frUrl: text('fr_url')
|
||||
});
|
||||
|
||||
export type CharacterScrapeValidation = InferSelectModel<typeof characterScrapeValidation>;
|
||||
|
||||
// Define the character history table schema
|
||||
export const characterHistory = sqliteTable('character_history', {
|
||||
id: text('id')
|
||||
@@ -120,6 +131,8 @@ export const characterHistory = sqliteTable('character_history', {
|
||||
updatedAt: integer('updated_at').notNull().$default(() => Date.now()),
|
||||
});
|
||||
|
||||
export type CharacterHistory = InferSelectModel<typeof characterHistory>;
|
||||
|
||||
// Define the user character history table schema
|
||||
export const userCharacterHistory = sqliteTable('user_character_history', {
|
||||
id: text('id')
|
||||
@@ -134,6 +147,8 @@ export const userCharacterHistory = sqliteTable('user_character_history', {
|
||||
unique().on(table.userId, table.characterHistoryId)
|
||||
]);
|
||||
|
||||
export type UserCharacterHistory = InferSelectModel<typeof userCharacterHistory>;
|
||||
|
||||
// Define the friendship table schema (friend requests + accepted friends)
|
||||
export const friendship = sqliteTable('friendship', {
|
||||
id: text('id')
|
||||
@@ -152,5 +167,6 @@ export const friendship = sqliteTable('friendship', {
|
||||
unique().on(table.requesterId, table.addresseeId)
|
||||
]);
|
||||
|
||||
export type Friendship = InferSelectModel<typeof friendship>;
|
||||
|
||||
export * from './auth.schema';
|
||||
|
||||
Reference in New Issue
Block a user