export const tables = {
  users: 'wm_users',
  sessions: 'wm_sessions',
  posts: 'wm_posts',
  postImages: 'wm_post_images',
  comments: 'wm_comments',
  likes: 'wm_likes',
  links: 'wm_links',
  settings: 'wm_settings',
  auditLog: 'wm_audit_log'
} as const;

export interface DbUserRow {
  id: string;
  username: string;
  email: string;
  display_name: string;
  avatar_key: string | null;
  bio: string | null;
  url: string | null;
  password_hash: string;
  role: 'subscriber' | 'author' | 'admin';
  status: 'active' | 'banned' | 'pending';
  created_at: number;
  updated_at: number;
  last_login_at: number | null;
}

export interface DbPostRow {
  id: string;
  author_id: string;
  type: 'moment' | 'article';
  visibility: 'public' | 'private';
  status: 'published' | 'draft' | 'trash';
  is_top: number;
  is_ad: number;
  title: string | null;
  content: string;
  content_html: string;
  video_key: string | null;
  position: string | null;
  position_lat: number | null;
  position_lng: number | null;
  share_url: string | null;
  share_thumb: string | null;
  like_count: number;
  comment_count: number;
  created_at: number;
  updated_at: number;
}

export interface DbPostImageRow {
  post_id: string;
  position: number;
  r2_key: string;
  width: number | null;
  height: number | null;
}

export interface DbCommentRow {
  id: string;
  post_id: string;
  parent_id: string | null;
  user_id: string | null;
  guest_name: string | null;
  guest_email: string | null;
  guest_url: string | null;
  content: string;
  status: 'approved' | 'pending' | 'spam' | 'trash';
  ip: string | null;
  user_agent: string | null;
  created_at: number;
}
