// Auto-generated SQLite schema
import type { Database } from "sql.js";

export function createTables(db: Database): void {
  const statements = [
  "CREATE TABLE IF NOT EXISTS users (\n  id TEXT PRIMARY KEY DEFAULT (lower(hex(randomblob(16)))),\n  username TEXT NOT NULL UNIQUE,\n  password_hash TEXT NOT NULL,\n  nickname TEXT,\n  role TEXT DEFAULT 'user',\n  phone TEXT,\n  avatar_url TEXT,\n  created_at TEXT,\n  updated_at TEXT\n);",
  "CREATE TABLE IF NOT EXISTS pets (\n  id TEXT PRIMARY KEY DEFAULT (lower(hex(randomblob(16)))),\n  user_id TEXT NOT NULL REFERENCES users(id),\n  name TEXT NOT NULL,\n  species TEXT,\n  breed TEXT,\n  birth_date TEXT,\n  weight_kg REAL,\n  avatar_url TEXT,\n  created_at TEXT,\n  updated_at TEXT\n);",
  "CREATE TABLE IF NOT EXISTS schedules (\n  id TEXT PRIMARY KEY DEFAULT (lower(hex(randomblob(16)))),\n  user_id TEXT REFERENCES users(id),\n  course_id TEXT REFERENCES courses(id),\n  classroom_id TEXT REFERENCES classrooms(id),\n  instructor_id TEXT REFERENCES instructors(id),\n  day_of_week INTEGER,\n  start_time TEXT,\n  end_time TEXT,\n  created_at TEXT,\n  updated_at TEXT\n);",
  "CREATE TABLE IF NOT EXISTS records (\n  id TEXT PRIMARY KEY DEFAULT (lower(hex(randomblob(16)))),\n  user_id TEXT REFERENCES users(id),\n  title TEXT NOT NULL,\n  description TEXT,\n  status TEXT,\n  data TEXT,\n  created_at TEXT,\n  updated_at TEXT\n);",
  "CREATE TABLE IF NOT EXISTS albums (\n  id TEXT PRIMARY KEY DEFAULT (lower(hex(randomblob(16)))),\n  user_id TEXT REFERENCES users(id),\n  title TEXT,\n  image_url TEXT NOT NULL,\n  caption TEXT,\n  taken_at TEXT,\n  created_at TEXT,\n  updated_at TEXT\n);",
  "CREATE TABLE IF NOT EXISTS hospitals (\n  id TEXT PRIMARY KEY DEFAULT (lower(hex(randomblob(16)))),\n  user_id TEXT REFERENCES users(id),\n  name TEXT NOT NULL,\n  address TEXT,\n  phone TEXT,\n  rating REAL,\n  lat REAL,\n  lng REAL,\n  created_at TEXT,\n  updated_at TEXT\n);",
  "CREATE TABLE IF NOT EXISTS items (\n  id TEXT PRIMARY KEY DEFAULT (lower(hex(randomblob(16)))),\n  user_id TEXT REFERENCES users(id),\n  title TEXT NOT NULL,\n  description TEXT,\n  status TEXT,\n  data TEXT,\n  created_at TEXT,\n  updated_at TEXT\n);",
  "CREATE TABLE IF NOT EXISTS daily-logs (\n  id TEXT PRIMARY KEY DEFAULT (lower(hex(randomblob(16)))),\n  user_id TEXT REFERENCES users(id),\n  title TEXT NOT NULL,\n  data TEXT,\n  created_at TEXT,\n  updated_at TEXT\n);"
  ];
  for (const sql of statements) {
    const trimmed = sql.trim();
    if (trimmed) db.run(trimmed);
  }
}
