Each cost item's name, amount, currency, period and kind are kept as versions (cost_item_versions), and Hetzner's estimate is written down once a day (cost_snapshots), so a past month's figure and the changes between can be worked out. History card with monthly bars per currency, month-by-month figures and a list of added, changed and removed items. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
22 lines
602 B
SQL
22 lines
602 B
SQL
CREATE TABLE `cost_item_versions` (
|
|
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
|
|
`item_id` integer NOT NULL,
|
|
`name` text NOT NULL,
|
|
`amount` real NOT NULL,
|
|
`currency` text NOT NULL,
|
|
`period` text NOT NULL,
|
|
`category` text NOT NULL,
|
|
`valid_from` text NOT NULL,
|
|
`valid_to` text
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE INDEX `cost_item_versions_item_idx` ON `cost_item_versions` (`item_id`);--> statement-breakpoint
|
|
CREATE TABLE `cost_snapshots` (
|
|
`day` text NOT NULL,
|
|
`key` text NOT NULL,
|
|
`name` text NOT NULL,
|
|
`currency` text NOT NULL,
|
|
`monthly` real NOT NULL,
|
|
PRIMARY KEY(`day`, `key`)
|
|
);
|