"""
GLAMWalk -- Volume 5: From Data to Product
02_unified_image_pool_schema.py

The unified image_pool database schema: one table referencing three different source types by pointer, carrying license and attribution as data on every row.

Source: Volume Five, Section 1.1 -- The Unification Problem
Targets Python 3.11.4 -- see Volume One, Chapter 1.5/1.6.
"""

import sqlite3

def create_image_pool_schema(conn):
    conn.execute("""
        CREATE TABLE IF NOT EXISTS image_pool (
            id INTEGER PRIMARY KEY,
            source_type TEXT NOT NULL,       -- 'museum', 'ai_generated', 'book_illustration'
            source_reference TEXT NOT NULL,  -- the canonical_id / filename / whatever THAT
                                              -- source's own table uses as its real key —
                                              -- a pointer, never a copy of the file itself
            title TEXT,
            description TEXT,
            license TEXT,
            attribution_text TEXT,
            requires_attribution INTEGER DEFAULT 0,
            requires_share_alike INTEGER DEFAULT 0,
            tags_cache TEXT                  -- see Chapter 2
        )
    """)
