"""
Migration script: create SQLite memos DB for local/dev.
"""

import asyncio
import os
import sys
from pathlib import Path

ROOT_DIR = Path(__file__).resolve().parent.parent
if str(ROOT_DIR) not in sys.path:
    sys.path.insert(0, str(ROOT_DIR))

from memos_core.db import DB_PATH, init_memo_db


async def main():
    print(f"Initializing memo DB at: {DB_PATH}")
    await init_memo_db()
    if os.path.exists(DB_PATH):
        size = os.path.getsize(DB_PATH)
        print(f"Done. DB file created ({size} bytes).")
    else:
        print("Warning: DB file not found after init.")


if __name__ == "__main__":
    # Ensure parent dir exists
    Path(DB_PATH).parent.mkdir(parents=True, exist_ok=True)
    asyncio.run(main())
