refactor code to fewer files; remove unused code
This commit is contained in:
@@ -5,7 +5,6 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
_ "github.com/mattn/go-sqlite3" // Import the SQLite3 driver
|
||||
"go-nkode/sql-driver"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"path/filepath"
|
||||
@@ -28,7 +27,7 @@ func main() {
|
||||
dbPaths := []string{"test.db", "nkode.db"}
|
||||
outputStr := MakeSvgFiles()
|
||||
for _, path := range dbPaths {
|
||||
sql_driver.MakeTables(path)
|
||||
MakeTables(path)
|
||||
SaveToSqlite(path, outputStr)
|
||||
}
|
||||
}
|
||||
@@ -136,3 +135,67 @@ func LoadJson(filename string) (*Root, error) {
|
||||
|
||||
return &root, nil
|
||||
}
|
||||
|
||||
func MakeTables(dbPath string) {
|
||||
db, err := sql.Open("sqlite3", dbPath)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer db.Close()
|
||||
createTable := `
|
||||
PRAGMA journal_mode=WAL;
|
||||
PRAGMA foreign_keys = ON;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS customer (
|
||||
id TEXT NOT NULL PRIMARY KEY,
|
||||
max_nkode_len INTEGER NOT NULL,
|
||||
min_nkode_len INTEGER NOT NULL,
|
||||
distinct_sets INTEGER NOT NULL,
|
||||
distinct_attributes INTEGER NOT NULL,
|
||||
lock_out INTEGER NOT NULL,
|
||||
expiration INTEGER NOT NULL,
|
||||
attribute_values BLOB NOT NULL,
|
||||
set_values BLOB NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS user (
|
||||
id TEXT NOT NULL PRIMARY KEY,
|
||||
username TEXT NOT NULL,
|
||||
renew INT NOT NULL,
|
||||
customer_id TEXT NOT NULL,
|
||||
|
||||
-- Enciphered Passcode
|
||||
code TEXT NOT NULL,
|
||||
mask TEXT NOT NULL,
|
||||
|
||||
-- Keypad Dimensions
|
||||
attributes_per_key INT NOT NULL,
|
||||
number_of_keys INT NOT NULL,
|
||||
|
||||
-- User Keys
|
||||
alpha_key BLOB NOT NULL,
|
||||
set_key BLOB NOT NULL,
|
||||
pass_key BLOB NOT NULL,
|
||||
mask_key BLOB NOT NULL,
|
||||
salt BLOB NOT NULL,
|
||||
max_nkode_len INT NOT NULL,
|
||||
|
||||
-- User Interface
|
||||
idx_interface BLOB NOT NULL,
|
||||
svg_id_interface BLOB NOT NULL,
|
||||
|
||||
|
||||
FOREIGN KEY (customer_id) REFERENCES customers(id),
|
||||
UNIQUE(customer_id, username)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS svg_icon (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
svg TEXT NOT NULL
|
||||
);
|
||||
`
|
||||
_, err = db.Exec(createTable)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user