
Replit-Commit-Author: Agent Replit-Commit-Session-Id: e931b5ab-041b-42e7-baf1-50017869cef6 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/e19c6a51-7e4c-4bb8-a6a6-46dc00f0ec99/3a46e308-0211-4c54-a52b-c291792321ef.jpg
67 lines
1.9 KiB
TypeScript
67 lines
1.9 KiB
TypeScript
import { pgTable, text, serial, integer, boolean, timestamp, jsonb } from "drizzle-orm/pg-core";
|
|
import { createInsertSchema } from "drizzle-zod";
|
|
import { z } from "zod";
|
|
|
|
export const species = pgTable("species", {
|
|
id: serial("id").primaryKey(),
|
|
scientificName: text("scientific_name").notNull(),
|
|
commonName: text("common_name"),
|
|
rank: text("rank"),
|
|
kingdom: text("kingdom"),
|
|
phylum: text("phylum"),
|
|
class: text("class"),
|
|
order: text("order"),
|
|
family: text("family"),
|
|
genus: text("genus"),
|
|
citesListings: jsonb("cites_listings"),
|
|
citesId: integer("cites_id"),
|
|
apiData: jsonb("api_data"),
|
|
searchedAt: timestamp("searched_at").defaultNow(),
|
|
});
|
|
|
|
export const insertSpeciesSchema = createInsertSchema(species).pick({
|
|
scientificName: true,
|
|
commonName: true,
|
|
rank: true,
|
|
kingdom: true,
|
|
phylum: true,
|
|
class: true,
|
|
order: true,
|
|
family: true,
|
|
genus: true,
|
|
citesListings: true,
|
|
citesId: true,
|
|
apiData: true,
|
|
});
|
|
|
|
export type InsertSpecies = z.infer<typeof insertSpeciesSchema>;
|
|
export type Species = typeof species.$inferSelect;
|
|
|
|
export const searches = pgTable("searches", {
|
|
id: serial("id").primaryKey(),
|
|
query: text("query").notNull(),
|
|
timestamp: timestamp("timestamp").defaultNow(),
|
|
});
|
|
|
|
export const insertSearchSchema = createInsertSchema(searches).pick({
|
|
query: true,
|
|
});
|
|
|
|
export type InsertSearch = z.infer<typeof insertSearchSchema>;
|
|
export type Search = typeof searches.$inferSelect;
|
|
|
|
export const apiTokens = pgTable("api_tokens", {
|
|
id: serial("id").primaryKey(),
|
|
token: text("token").notNull(),
|
|
isActive: boolean("is_active").default(true),
|
|
createdAt: timestamp("created_at").defaultNow(),
|
|
});
|
|
|
|
export const insertApiTokenSchema = createInsertSchema(apiTokens).pick({
|
|
token: true,
|
|
isActive: true,
|
|
});
|
|
|
|
export type InsertApiToken = z.infer<typeof insertApiTokenSchema>;
|
|
export type ApiToken = typeof apiTokens.$inferSelect;
|