func createDBTables() {
	openDB()
	defer theDB.Close()
	sql_cmd := `
	CREATE TABLE IF NOT EXISTS Artifacts (
		Id INTEGER PRIMARY KEY AUTOINCREMENT,
		UUID TEXT,
		Name TEXT,
		Alias TEXT,	
		Label TEXT,
		Checksum TEXT,
		ContentType TEXT,
		OpenChain TEXT,
		_contentPath TEXT,
		_envelopeUUID TEXT,
		_envelopePath TEXT,
		_onLedger TEXT,
		InsertedDatetime DATETIME
	);
	`
	_, err := theDB.Exec(sql_cmd)
	if err != nil {
		fmt.Println(err)
		fmt.Println("  fatal: sparts database table creation not feasible. ")
		os.Exit(3)
	}
	sql_cmd = `
	CREATE TABLE IF NOT EXISTS Parts (
		Id INTEGER PRIMARY KEY AUTOINCREMENT,
		UUID TEXT,
		Name TEXT,
		Version TEXT,
		Label TEXT,
		Alias TEXT,
		Licensing TEXT,
		Description  TEXT, 
		Checksum TEXT,
		InsertedDatetime DATETIME
	);
	`
	_, err = theDB.Exec(sql_cmd)
	if err != nil {
		fmt.Println(err)
		fmt.Println("  fatal: sparts database table creation not feasible. ")
		os.Exit(3)
	}
	sql_cmd = `
	CREATE TABLE IF NOT EXISTS Envelopes (
		Id INTEGER PRIMARY KEY AUTOINCREMENT,
		EnvelopeId INTEGER,
		ArtifactId INTEGER,
		Stage TEXT,	
		Path TEXT,
		InsertedDatetime DATETIME
	);
	`
	_, err = theDB.Exec(sql_cmd)
	if err != nil {
		fmt.Println(err)
		fmt.Printf("  fatal: sparts database table '%s' creation not feasible.\n", "Envelope")
		os.Exit(3)
	}
	sql_cmd = `
	CREATE TABLE IF NOT EXISTS  Aliases (
		Id INTEGER PRIMARY KEY AUTOINCREMENT,
		Alias TEXT,
		Value TEXT,
		InsertedDatetime DATETIME
	);
	`
	_, err = theDB.Exec(sql_cmd)
	if err != nil {
		fmt.Println(err)
		fmt.Println("  fatal: Could not create sparts database table: Aliases")
		os.Exit(3)
	}
	sql_cmd = `CREATE UNIQUE INDEX idx_Apps_Alias 
				ON Aliases (Alias);`
	_, err = theDB.Exec(sql_cmd)
	if err != nil {
		fmt.Println(err)
	}
}
Create database tables
package main
import (
	"database/sql"
	"encoding/json"
	"errors"
	"fmt"
	"os"
	"strings"
	_ "github.com/mattn/go-sqlite3"
)
var theDB *sql.DB
const CONFIG_RECORD = "Config_Info"
func checkErr(err error) {
	if err != nil {
		fmt.Println(err)
	}
}
func openDB() {
	var err error
	spartsDir, err := getSpartsDirectory()
	if err != nil {
		fmt.Println(err)
		fmt.Println("  fatal: sparts working directory not accessible.")
		os.Exit(_DIR_ACCESS_ERROR)
	}
	theDB, err = sql.Open("sqlite3", spartsDir+"/"+_LOCAL_DB_FILE)
	if err != nil {
		fmt.Println("  fatal: sparts working directory database is not accessible.")
		os.Exit(_DB_ACCESSS_ERROR)
	}
}
func initializeDB() {
	createDBTables()
}