Download tasks/article/solution/site/implementation/clone/site_schema.py from TIGER-Lab/WebsiteBench: direct link, hf CLI and curl.
- Browser
- Download file 2.49 kB
-
https://huggingface.co/datasets/TIGER-Lab/WebsiteBench/resolve/main/tasks/article/solution/site/implementation/clone/site_schema.py
- Command line
-
hf download hf://datasets/TIGER-Lab/WebsiteBench/tasks/article/solution/site/implementation/clone/site_schema.py
-
curl -L -o site_schema.py https://huggingface.co/datasets/TIGER-Lab/WebsiteBench/resolve/main/tasks/article/solution/site/implementation/clone/site_schema.py
2.49 kB
| """Business schema and deterministic seed for site_id=article. | |
| Opened through the generated backend integration seam only; the tables live in | |
| this site's own bound SQLite database (volume identity websitebench-article-data). | |
| """ | |
| from __future__ import annotations | |
| import sqlite3 | |
| SYNTHETIC_ACCOUNTS = [ | |
| { | |
| "subject_id": "article-shopper-1", | |
| "email": "shopper@article.test", | |
| "display_name": "Alex Shopper", | |
| "password": "ArticleDemo!2026", | |
| }, | |
| ] | |
| def migrate(connection: sqlite3.Connection) -> None: | |
| """Create the cart, favorite and order tables this clone owns.""" | |
| connection.execute( | |
| """ | |
| CREATE TABLE IF NOT EXISTS article_cart_items ( | |
| cart_item_id INTEGER PRIMARY KEY AUTOINCREMENT, | |
| owner_key TEXT NOT NULL, | |
| product_id TEXT NOT NULL, | |
| quantity INTEGER NOT NULL CHECK (quantity > 0), | |
| created_at INTEGER NOT NULL, | |
| UNIQUE (owner_key, product_id) | |
| ) | |
| """ | |
| ) | |
| connection.execute( | |
| "CREATE INDEX IF NOT EXISTS article_cart_owner ON article_cart_items(owner_key)" | |
| ) | |
| connection.execute( | |
| """ | |
| CREATE TABLE IF NOT EXISTS article_favorites ( | |
| favorite_id INTEGER PRIMARY KEY AUTOINCREMENT, | |
| owner_key TEXT NOT NULL, | |
| product_id TEXT NOT NULL, | |
| created_at INTEGER NOT NULL, | |
| UNIQUE (owner_key, product_id) | |
| ) | |
| """ | |
| ) | |
| connection.execute( | |
| """ | |
| CREATE TABLE IF NOT EXISTS article_orders ( | |
| order_id INTEGER PRIMARY KEY AUTOINCREMENT, | |
| order_number TEXT NOT NULL UNIQUE, | |
| owner_key TEXT NOT NULL, | |
| email TEXT NOT NULL, | |
| ship_to TEXT NOT NULL, | |
| subtotal_cents INTEGER NOT NULL, | |
| created_at INTEGER NOT NULL | |
| ) | |
| """ | |
| ) | |
| connection.execute( | |
| """ | |
| CREATE TABLE IF NOT EXISTS article_order_items ( | |
| order_item_id INTEGER PRIMARY KEY AUTOINCREMENT, | |
| order_id INTEGER NOT NULL REFERENCES article_orders(order_id), | |
| product_id TEXT NOT NULL, | |
| name TEXT NOT NULL, | |
| unit_cents INTEGER NOT NULL, | |
| quantity INTEGER NOT NULL | |
| ) | |
| """ | |
| ) | |
| def seed(connection: sqlite3.Connection) -> None: | |
| """No business rows are pre-seeded; the catalog is a read-only fixture.""" | |
| return None | |