/**
 * Delade kolumnhjälpare och pg-enums för hela schemat.
 * Alla enum-värden kommer från @app/shared-types så att databas,
 * API och app aldrig glider isär.
 */
import { pgEnum, timestamp } from "drizzle-orm/pg-core";
import {
  ACTIVITY_LEVELS,
  ALLERGENS,
  CONSENT_KINDS,
  CONSENT_STATUSES,
  COOKING_METHODS,
  CREATOR_LEVELS,
  CUISINES,
  DATE_KINDS,
  DIET_PATTERNS,
  EVENT_TYPES,
  EXPIRY_STATUSES,
  GOAL_TYPES,
  HOUSEHOLD_ROLES,
  INVENTORY_SOURCES,
  INVENTORY_TRANSACTION_TYPES,
  JOB_STATUSES,
  JOB_TYPES,
  MEAL_LOG_SOURCES,
  MEAL_TYPES,
  MEMORY_KINDS,
  NOTIFICATION_TYPES,
  PRECISION_MODES,
  PROFILE_VISIBILITIES,
  RECIPE_DIFFICULTIES,
  RECIPE_SIMILARITY_CLASSES,
  RECIPE_SOURCE_TYPES,
  RECIPE_STATUSES,
  RECIPE_VARIANT_TYPES,
  RECIPE_VERIFICATION_STATUSES,
  RELIGIOUS_RULES,
  SCAN_TYPES,
  SEXES,
  SIGNAL_ORIGINS,
  STORAGE_LOCATION_TYPES,
  SUBSCRIPTION_PLANS,
  SUBSCRIPTION_PROVIDERS,
  SUBSCRIPTION_STATUSES,
  TASTE_AXES,
  UNITS,
  USER_ROLES,
  VERIFICATION_STATUSES,
  tuple,
} from "@app/shared-types";

// --- Tidsstämplar som återanvänds av alla tabeller ---
export const createdAt = () =>
  timestamp("created_at", { withTimezone: true }).notNull().defaultNow();
export const updatedAt = () =>
  timestamp("updated_at", { withTimezone: true }).notNull().defaultNow();

// --- pg-enums ---
export const userRoleEnum = pgEnum("user_role", tuple(USER_ROLES));
export const sexEnum = pgEnum("sex", tuple(SEXES));
export const activityLevelEnum = pgEnum("activity_level", tuple(ACTIVITY_LEVELS));
export const goalTypeEnum = pgEnum("goal_type", tuple(GOAL_TYPES));
export const dietPatternEnum = pgEnum("diet_pattern", tuple(DIET_PATTERNS));
export const religiousRuleEnum = pgEnum("religious_rule", tuple(RELIGIOUS_RULES));
export const precisionModeEnum = pgEnum("precision_mode", tuple(PRECISION_MODES));
export const allergenEnum = pgEnum("allergen", tuple(ALLERGENS));
export const consentKindEnum = pgEnum("consent_kind", tuple(CONSENT_KINDS));
export const consentStatusEnum = pgEnum("consent_status", tuple(CONSENT_STATUSES));
export const householdRoleEnum = pgEnum("household_role", tuple(HOUSEHOLD_ROLES));
export const storageLocationTypeEnum = pgEnum(
  "storage_location_type",
  tuple(STORAGE_LOCATION_TYPES),
);
export const unitEnum = pgEnum("unit", tuple(UNITS));
export const inventorySourceEnum = pgEnum("inventory_source", tuple(INVENTORY_SOURCES));
export const inventoryTransactionTypeEnum = pgEnum(
  "inventory_transaction_type",
  tuple(INVENTORY_TRANSACTION_TYPES),
);
export const expiryStatusEnum = pgEnum("expiry_status", tuple(EXPIRY_STATUSES));
export const dateKindEnum = pgEnum("date_kind", tuple(DATE_KINDS));
export const cuisineEnum = pgEnum("cuisine", tuple(CUISINES));
export const mealTypeEnum = pgEnum("meal_type", tuple(MEAL_TYPES));
export const cookingMethodEnum = pgEnum("cooking_method", tuple(COOKING_METHODS));
export const recipeDifficultyEnum = pgEnum("recipe_difficulty", tuple(RECIPE_DIFFICULTIES));
export const recipeStatusEnum = pgEnum("recipe_status", tuple(RECIPE_STATUSES));
export const recipeVerificationStatusEnum = pgEnum(
  "recipe_verification_status",
  tuple(RECIPE_VERIFICATION_STATUSES),
);
export const recipeVariantTypeEnum = pgEnum("recipe_variant_type", tuple(RECIPE_VARIANT_TYPES));
export const recipeSourceTypeEnum = pgEnum("recipe_source_type", tuple(RECIPE_SOURCE_TYPES));
export const recipeSimilarityClassEnum = pgEnum(
  "recipe_similarity_class",
  tuple(RECIPE_SIMILARITY_CLASSES),
);
export const scanTypeEnum = pgEnum("scan_type", tuple(SCAN_TYPES));
export const jobTypeEnum = pgEnum("job_type", tuple(JOB_TYPES));
export const jobStatusEnum = pgEnum("job_status", tuple(JOB_STATUSES));
export const eventTypeEnum = pgEnum("event_type", tuple(EVENT_TYPES));
export const mealLogSourceEnum = pgEnum("meal_log_source", tuple(MEAL_LOG_SOURCES));
export const memoryKindEnum = pgEnum("memory_kind", tuple(MEMORY_KINDS));
export const signalOriginEnum = pgEnum("signal_origin", tuple(SIGNAL_ORIGINS));
export const tasteAxisEnum = pgEnum("taste_axis", tuple(TASTE_AXES));
export const subscriptionPlanEnum = pgEnum("subscription_plan", tuple(SUBSCRIPTION_PLANS));
export const subscriptionStatusEnum = pgEnum("subscription_status", tuple(SUBSCRIPTION_STATUSES));
export const subscriptionProviderEnum = pgEnum(
  "subscription_provider",
  tuple(SUBSCRIPTION_PROVIDERS),
);
export const creatorLevelEnum = pgEnum("creator_level", tuple(CREATOR_LEVELS));
export const profileVisibilityEnum = pgEnum("profile_visibility", tuple(PROFILE_VISIBILITIES));
export const notificationTypeEnum = pgEnum("notification_type", tuple(NOTIFICATION_TYPES));
export const verificationStatusEnum = pgEnum("verification_status", tuple(VERIFICATION_STATUSES));
