diff --git a/db/schemas/sqlite-create.sql b/db/schemas/sqlite-create.sql index c958876..069d6a9 100644 --- a/db/schemas/sqlite-create.sql +++ b/db/schemas/sqlite-create.sql @@ -1,53 +1,53 @@ CREATE TABLE IF NOT EXISTS [ServerSettings] ( - [settingID] INTEGER PRIMARY KEY, - [name] TEXT NOT NULL, - [description] TEXT NOT NULL, - [value] TEXT NOT NULL + [settingID] INTEGER PRIMARY KEY, + [name] TEXT NOT NULL, + [description] TEXT NOT NULL, + [value] TEXT NOT NULL ); CREATE TABLE IF NOT EXISTS [Users] ( - [userID] INTEGER PRIMARY KEY, - [name] TEXT NOT NULL, - [email] TEXT, - [authType] TEXT NOT NULL, - [salt] TEXT, - [hashedPWSalt] TEXT + [userID] INTEGER PRIMARY KEY, + [name] TEXT NOT NULL, + [email] TEXT, + [authType] TEXT NOT NULL, + [salt] TEXT, + [hashedPWSalt] TEXT ); CREATE TABLE IF NOT EXISTS [MediaItems] ( - [mediaID] INTEGER PRIMARY KEY, - [userID] INTEGER NOT NULL, - [EXIFDate] TEXT NOT NULL, - [uploadDate] TEXT NOT NULL, - [latitude] TEXT, - [longitude] TEXT, - [mediaType] INTEGER, /* 0 = Photo, 1 = Video */ - [relPath] TEXT NOT NULL, + [mediaID] INTEGER PRIMARY KEY, + [userID] INTEGER NOT NULL, + [EXIFDate] TEXT NOT NULL, + [uploadDate] TEXT NOT NULL, + [latitude] TEXT, + [longitude] TEXT, + [mediaType] INTEGER, /* 0 = Photo, 1 = Video */ + [relPath] TEXT NOT NULL, FOREIGN KEY (userID) REFERENCES Users(userID) ); CREATE TABLE IF NOT EXISTS [Tags] ( - [tagID] INTEGER PRIMARY KEY, + [tagID] INTEGER PRIMARY KEY, [name] TEXT NOT NULL ); CREATE TABLE IF NOT EXISTS [MediaTags] ( - [mediaID] INTEGER NOT NULL, - [tagID] INTEGER NOT NULL, + [mediaID] INTEGER NOT NULL, + [tagID] INTEGER NOT NULL, FOREIGN KEY (mediaID) REFERENCES MediaItems(mediaID) FOREIGN KEY (tagID) REFERENCES Tags(tagID) ); CREATE TABLE IF NOT EXISTS [Albums] ( - [albumID] INTEGER PRIMARY KEY, + [albumID] INTEGER PRIMARY KEY, [userID] INTEGER NOT NULL, [name] TEXT NOT NULL, FOREIGN KEY (userID) REFERENCES Users(userID) ); CREATE TABLE IF NOT EXISTS [MediaAlbums] ( - [mediaID] INTEGER NOT NULL, - [albumID] INTEGER NOT NULL, + [mediaID] INTEGER NOT NULL, + [albumID] INTEGER NOT NULL, FOREIGN KEY (mediaID) REFERENCES MediaItems(mediaID) FOREIGN KEY (albumID) REFERENCES Albums(albumID) ); diff --git a/db/sqlite.go b/db/sqlite.go index 0eb70ff..dc1635f 100644 --- a/db/sqlite.go +++ b/db/sqlite.go @@ -8,14 +8,14 @@ import ( ) type MediaItem struct { - mediaID int - userID int - EXIFDate string - uploadDate string - latitude string - longitude string - mediaType int - relPath string + mediaID int + userID int + EXIFDate string + uploadDate string + latitude string + longitude string + mediaType int + relPath string } func init() { @@ -23,8 +23,8 @@ func init() { } func ItemsFromAlbum(userID int, albumID int) []MediaItem { - database, _ := sql.Open("sqlite3", "./db/imagini.db") - rows, _ := database.Query(` + database, _ := sql.Open("sqlite3", "./db/imagini.db") + rows, _ := database.Query(` SELECT MediaItems.* FROM @@ -46,8 +46,8 @@ func ItemsFromAlbum(userID int, albumID int) []MediaItem { } func ItemsFromTags(userID int, tagID int) []MediaItem { - database, _ := sql.Open("sqlite3", "./db/imagini.db") - rows, _ := database.Query(` + database, _ := sql.Open("sqlite3", "./db/imagini.db") + rows, _ := database.Query(` SELECT MediaItems.* FROM @@ -69,7 +69,7 @@ func ItemsFromTags(userID int, tagID int) []MediaItem { } func IndexMediaItems(newItems []MediaItem) { - database, _ := sql.Open("sqlite3", "./db/imagini.db") + database, _ := sql.Open("sqlite3", "./db/imagini.db") statement, _ := database.Prepare(` INSERT INTO MediaItems ( userID, diff --git a/main.go b/main.go index de61315..27326fc 100644 --- a/main.go +++ b/main.go @@ -1,8 +1,8 @@ package main import ( - "os" - "log" + "os" + "log" "reichard.io/imagini/cmd" "github.com/urfave/cli/v2" )