summary refs log tree commit diff stats
path: root/storage
diff options
context:
space:
mode:
Diffstat (limited to 'storage')
-rw-r--r--storage/init.go (renamed from storage/sqlite3/init.go)15
-rw-r--r--storage/sqlite3/db.go13
-rw-r--r--storage/storage.go16
3 files changed, 18 insertions, 26 deletions
diff --git a/storage/sqlite3/init.go b/storage/init.go
index e79d3ff..2103498 100644
--- a/storage/sqlite3/init.go
+++ b/storage/init.go
@@ -1,4 +1,4 @@
-package sqlite3
+package storage
 
 import (
 	"database/sql"
@@ -17,8 +17,7 @@ func initErr(db *DB, err error) {
 	log.Fatalf("Initialization Error :: %s", err.Error())
 }
 
-// Init initializes a sqlite3 database.
-func Init(db *DB) {
+func initDB(db *DB) {
 	var err error
 
 	// We set the database path, first the environment variable
@@ -36,7 +35,7 @@ func Init(db *DB) {
 	db.Conn, err = sql.Open("sqlite3", db.Path)
 	if err != nil {
 		log.Printf("sqlite3/init.go: %s\n",
-			"Failed to open database connection")
+			"failed to open database connection")
 		initErr(db, err)
 	}
 
@@ -50,11 +49,11 @@ func Init(db *DB) {
        token    TEXT NOT NULL,
        genTime TEXT NOT NULL);`,
 
-		`CREATE TABLE IF NOT EXISTS users (
+		`CREATE TABLE IF NOT EXISTS accounts (
        id       TEXT PRIMARY KEY,
        type     TEXT NOT NULL DEFAULT user,
        username VARCHAR(128) NOT NULL UNIQUE,
-       password TEXT NOT NULL,
+       hash     TEXT NOT NULL,
        regTime  TEXT NOT NULL);`,
 	}
 
@@ -67,7 +66,7 @@ func Init(db *DB) {
 
 		if err != nil {
 			log.Printf("sqlite3/init.go: %s\n",
-				"Failed to prepare statement")
+				"failed to prepare statement")
 			log.Println(s)
 			initErr(db, err)
 		}
@@ -76,7 +75,7 @@ func Init(db *DB) {
 		stmt.Close()
 		if err != nil {
 			log.Printf("sqlite3/init.go: %s\n",
-				"Failed to execute statement")
+				"failed to execute statement")
 			log.Println(s)
 			initErr(db, err)
 		}
diff --git a/storage/sqlite3/db.go b/storage/sqlite3/db.go
deleted file mode 100644
index e949bba..0000000
--- a/storage/sqlite3/db.go
+++ /dev/null
@@ -1,13 +0,0 @@
-package sqlite3
-
-import (
-	"database/sql"
-	"sync"
-)
-
-// DB holds the database connection, mutex & path.
-type DB struct {
-	Path string
-	Mu   *sync.RWMutex
-	Conn *sql.DB
-}
diff --git a/storage/storage.go b/storage/storage.go
index 24f770d..33dd29f 100644
--- a/storage/storage.go
+++ b/storage/storage.go
@@ -1,17 +1,23 @@
 package storage
 
 import (
+	"database/sql"
 	"sync"
-
-	"tildegit.org/andinus/perseus/storage/sqlite3"
 )
 
+// DB holds the database connection, mutex & path.
+type DB struct {
+	Path string
+	Mu   *sync.RWMutex
+	Conn *sql.DB
+}
+
 // Init initializes the database.
-func Init() *sqlite3.DB {
-	var db sqlite3.DB = sqlite3.DB{
+func Init() *DB {
+	db := DB{
 		Mu: new(sync.RWMutex),
 	}
 
-	sqlite3.Init(&db)
+	initDB(&db)
 	return &db
 }