CREATE TABLE `estimate_balances` ( `id` text PRIMARY KEY NOT NULL, `project_id` text NOT NULL, `name` text NOT NULL, `work_stage` text, `date_iso` text, `reserve_av_percent` real DEFAULT 0 NOT NULL, `reserve_sv_percent` real DEFAULT 0 NOT NULL, `sort_order` integer DEFAULT 0 NOT NULL, FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE no action ON DELETE cascade ); --> statement-breakpoint CREATE INDEX `estimate_balances_project_id_idx` ON `estimate_balances` (`project_id`);--> statement-breakpoint CREATE TABLE `estimate_groups` ( `id` text PRIMARY KEY NOT NULL, `balance_id` text NOT NULL, `cost_group` text DEFAULT '' NOT NULL, `title` text NOT NULL, `editor` text, `sort_order` integer DEFAULT 0 NOT NULL, FOREIGN KEY (`balance_id`) REFERENCES `estimate_balances`(`id`) ON UPDATE no action ON DELETE cascade ); --> statement-breakpoint CREATE INDEX `estimate_groups_balance_id_idx` ON `estimate_groups` (`balance_id`);--> statement-breakpoint CREATE TABLE `estimate_rows` ( `id` text PRIMARY KEY NOT NULL, `group_id` text NOT NULL, `sort_order` integer DEFAULT 0 NOT NULL, `supply` text, `name` text DEFAULT '' NOT NULL, `quantity` real DEFAULT 0 NOT NULL, `unit` text DEFAULT 'piece' NOT NULL, `connection` text, `power_per_unit_w` real DEFAULT 0 NOT NULL, `simultaneity_factor` real DEFAULT 1 NOT NULL, `cos_phi` real DEFAULT 1 NOT NULL, `safety_supply` integer DEFAULT false NOT NULL, `remark` text, FOREIGN KEY (`group_id`) REFERENCES `estimate_groups`(`id`) ON UPDATE no action ON DELETE cascade ); --> statement-breakpoint CREATE INDEX `estimate_rows_group_id_idx` ON `estimate_rows` (`group_id`);