⚡ SONAN TECH

Location Launchpad Docs

Database Guide← Docs Home

Database Guide

Schema overview, tables, relationships, and sample queries for the SONAN Location Launchpad D1 database.

Tables

locations

Core table. One row per store location.

ColumnTypeNotes
idINTEGER PKAuto-increment
nameTEXTRequired. e.g. "SONAN TECH Wood Ridge"
statusTEXTPlanning | Lease Signed | Buildout | Pre-Opening | Open | Archived
target_opening_dateTEXTISO date string YYYY-MM-DD
rent_commencement_dateTEXTISO date string
ti_allowanceREALDollar amount
monthly_rentREALDollar amount

task_templates

Master template. Tasks auto-generated from this when a location is created.

ColumnTypeNotes
idINTEGER PK
categoryTEXTe.g. "Buildout", "Signage"
titleTEXTTask name
default_priorityTEXTLow | Normal | High | Critical
sort_orderINTEGERDisplay order within category
activeINTEGER1=active, 0=disabled

tasks

Tasks per location. Linked to a location via location_id.

ColumnTypeNotes
idINTEGER PK
location_idINTEGER FK→ locations.id (CASCADE DELETE)
template_idINTEGER FK→ task_templates.id (nullable)
statusTEXTNot Started | In Progress | Waiting | Done | Blocked
priorityTEXTLow | Normal | High | Critical
due_dateTEXTISO date
completed_dateTEXTAuto-set when status → Done
link_urlTEXTLink to document or reference

budget_items

Budget line items per location.

ColumnTypeNotes
ti_eligibleTEXTYes | No | Maybe
paidINTEGER0=No, 1=Yes
estimated_costREALDollar amount
actual_costREALNullable until paid

Useful Queries

-- Location progress summary
SELECT l.name, l.status,
  COUNT(t.id) as total,
  SUM(CASE WHEN t.status='Done' THEN 1 ELSE 0 END) as done
FROM locations l
LEFT JOIN tasks t ON t.location_id = l.id
GROUP BY l.id;

-- All overdue tasks
SELECT t.title, t.due_date, l.name as location
FROM tasks t JOIN locations l ON l.id = t.location_id
WHERE t.due_date < date('now') AND t.status != 'Done'
ORDER BY t.due_date;

-- TI eligible budget total
SELECT SUM(estimated_cost) as ti_total
FROM budget_items
WHERE ti_eligible = 'Yes' AND location_id = 1;