import { bigint, bigserial, foreignKey, pgTable, text, timestamp } from "drizzle-orm/pg-core";
import { users } from "./User";

export const userActivityLog = pgTable("user_activity_log", {
    id: bigserial({ mode: "bigint" }).primaryKey().notNull(),
    // You can use { mode: "bigint" } if numbers are exceeding js number limitations
    userId: bigint("user_id", { mode: "number" }).notNull(),
    activity: text().notNull(),
    timestamp: timestamp({ mode: 'string' }).default(sql`CURRENT_TIMESTAMP`),
}, (table) => {
    return {
        userActivityLogUserIdFkey: foreignKey({
            columns: [table.userId],
            foreignColumns: [users.id],
            name: "user_activity_log_user_id_fkey"
        }).onDelete("cascade"),
    }
});
