ip.sql.ts 906 B

1234567891011121314151617181920212223242526272829303132
  1. import { mysqlTable, int, primaryKey, varchar } from "drizzle-orm/mysql-core"
  2. import { timestamps } from "../drizzle/types"
  3. export const IpTable = mysqlTable(
  4. "ip",
  5. {
  6. ip: varchar("ip", { length: 45 }).notNull(),
  7. ...timestamps,
  8. usage: int("usage"),
  9. },
  10. (table) => [primaryKey({ columns: [table.ip] })],
  11. )
  12. export const IpRateLimitTable = mysqlTable(
  13. "ip_rate_limit",
  14. {
  15. ip: varchar("ip", { length: 45 }).notNull(),
  16. interval: varchar("interval", { length: 10 }).notNull(),
  17. count: int("count").notNull(),
  18. },
  19. (table) => [primaryKey({ columns: [table.ip, table.interval] })],
  20. )
  21. export const KeyRateLimitTable = mysqlTable(
  22. "key_rate_limit",
  23. {
  24. key: varchar("key", { length: 255 }).notNull(),
  25. interval: varchar("interval", { length: 40 }).notNull(),
  26. count: int("count").notNull(),
  27. },
  28. (table) => [primaryKey({ columns: [table.key, table.interval] })],
  29. )