Restructure
New Journal entries
Colour tabs update with wind
This commit is contained in:
fraxle
2026-08-31 15:12:45 +01:00
parent 47818fba33
commit 71860b9dd9
40 changed files with 3430 additions and 443 deletions
+43
View File
@@ -0,0 +1,43 @@
-- SunScope Dashboard — initial schema.
-- Minimal v1: accounts (email + password) and journal entries.
-- No Stripe/entitlement linking yet — that stays in the front-end
-- localStorage Pro check for now, same as the rest of the site.
CREATE TABLE IF NOT EXISTS schema_migrations (
version VARCHAR(32) NOT NULL PRIMARY KEY,
applied_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS users (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
public_id CHAR(22) NOT NULL,
email VARCHAR(255) NOT NULL,
password_hash VARCHAR(255) NOT NULL,
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
UNIQUE KEY uq_users_public_id (public_id),
UNIQUE KEY uq_users_email (email)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS sessions (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
user_id BIGINT UNSIGNED NOT NULL,
token_hash BINARY(32) NOT NULL,
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
expires_at DATETIME NOT NULL,
KEY ix_sessions_user (user_id),
UNIQUE KEY uq_sessions_token_hash (token_hash),
CONSTRAINT fk_sessions_user FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS journal_entries (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
user_id BIGINT UNSIGNED NOT NULL,
entry_date DATE NOT NULL,
note TEXT NULL,
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
KEY ix_journal_user_date (user_id, entry_date),
CONSTRAINT fk_journal_user FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
INSERT IGNORE INTO schema_migrations (version) VALUES ('001_init');
+14
View File
@@ -0,0 +1,14 @@
-- Adds an optional computed reading to a journal entry, captured the same
-- way the day tabs derive their headline number: peak value of the active
-- profile's main field across that day's hourly forecast rows. Only
-- possible for dates inside the 14-day forecast window, so it's nullable -
-- older/out-of-range entries stay note-only.
ALTER TABLE journal_entries
ADD COLUMN profile VARCHAR(32) NULL AFTER note,
ADD COLUMN reading DECIMAL(5,1) NULL AFTER profile,
ADD COLUMN location_name VARCHAR(255) NULL AFTER reading,
ADD COLUMN lat DECIMAL(8,5) NULL AFTER location_name,
ADD COLUMN lon DECIMAL(8,5) NULL AFTER lat;
INSERT IGNORE INTO schema_migrations (version) VALUES ('002_add_reading');
+8
View File
@@ -0,0 +1,8 @@
-- The solar model (environment modifier) changes the SunSoak reading just
-- as much as the profile does, so a reading needs both stored to mean
-- anything when filtering the journal/graph by "what's currently selected".
ALTER TABLE journal_entries
ADD COLUMN solar_env VARCHAR(16) NULL AFTER profile;
INSERT IGNORE INTO schema_migrations (version) VALUES ('003_add_solar_env');
+8
View File
@@ -0,0 +1,8 @@
-- A note can now span a period rather than one day (e.g. a holiday week).
-- entry_date remains the start of the range; end_date is NULL for a
-- single-day entry, keeping every existing row valid with no backfill.
ALTER TABLE journal_entries
ADD COLUMN end_date DATE NULL AFTER entry_date;
INSERT IGNORE INTO schema_migrations (version) VALUES ('004_add_end_date');