]> Nutra Git (v1) - nutratech/usda-sqlite.git/commitdiff
wip format
authorShane Jaroch <chown_tee@proton.me>
Sat, 2 Mar 2024 17:22:30 +0000 (12:22 -0500)
committerShane Jaroch <chown_tee@proton.me>
Sat, 2 Mar 2024 17:22:30 +0000 (12:22 -0500)
Makefile
sql/format-sql.sh [deleted file]
sql/format.sh [new file with mode: 0755]
sql/tables.sql

index 9edc19a7e10d7633d8bc8d89b6d5b8d98edc80d1..c029d447b135a98b122d254f73b2bf2fc5721204 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -35,8 +35,8 @@ run:
        pnpm dev
 
 .PHONY: format
-format:        ## pnpm format
-       pnpm format
+format:        ## format SQL with pg_format
+       ./sql/format.sh
 
 .PHONY: lint
 lint:  ## pnpm lint && pnpm check
diff --git a/sql/format-sql.sh b/sql/format-sql.sh
deleted file mode 100755 (executable)
index 32b0965..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/bin/bash
-
-cd "$(dirname "$0")"
-
-pg_format -s 2 tables.sql -o tables.sql
-# pg_format -s 2 import.sql -o import.sql
diff --git a/sql/format.sh b/sql/format.sh
new file mode 100755 (executable)
index 0000000..8cc5c17
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+cd "$(dirname "$0")"
+
+# TODO: what about import.sql?  It gets formatted too ugly
+pg_format -L -s 2 -w 100 tables.sql >tables.fmt.sql
+mv tables.fmt.sql tables.sql
index 9196e3cfae7215142b5ce32250f57cde12a4d4bd..3b135aef42c902c95f2383127d4755d53b56dfcf 100644 (file)
 --
 -- You should have received a copy of the GNU General Public License
 -- along with this program.  If not, see <https://www.gnu.org/licenses/>.
-
-CREATE TABLE version( id integer PRIMARY KEY AUTOINCREMENT, version text NOT NULL, created timestamp DEFAULT CURRENT_TIMESTAMP, notes text
+CREATE TABLE version (
+  id integer PRIMARY KEY AUTOINCREMENT,
+  version text NOT NULL,
+  created timestamp DEFAULT CURRENT_TIMESTAMP,
+  notes text
 );
 
 CREATE TABLE nutr_def (
@@ -44,10 +47,10 @@ CREATE TABLE food_des (
   ref_desc text,
   refuse int,
   sci_name text,
-  n_factor FLOAT,
-  pro_factor FLOAT,
-  fat_factor FLOAT,
-  cho_factor FLOAT,
+  n_factor float,
+  pro_factor float,
+  fat_factor float,
+  cho_factor float,
   FOREIGN KEY (fdgrp_id) REFERENCES fdgrp (id)
 );
 
@@ -143,4 +146,3 @@ CREATE TABLE serving (
   FOREIGN KEY (food_id) REFERENCES food_des (id),
   FOREIGN KEY (msre_id) REFERENCES serv_desc (id)
 );
-