This repository has been archived on 2023-11-13. You can view files and clone it, but cannot push or open issues or pull requests.
imagini/db/schemas/sqlite-create.sql

54 lines
1.4 KiB
MySQL
Raw Normal View History

2021-01-04 05:16:58 +00:00
CREATE TABLE IF NOT EXISTS [ServerSettings] (
2021-01-04 06:55:41 +00:00
[settingID] INTEGER PRIMARY KEY,
[name] TEXT NOT NULL,
[description] TEXT NOT NULL,
[value] TEXT NOT NULL
2021-01-04 05:16:58 +00:00
);
CREATE TABLE IF NOT EXISTS [Users] (
2021-01-04 06:55:41 +00:00
[userID] INTEGER PRIMARY KEY,
[name] TEXT NOT NULL,
[email] TEXT,
[authType] TEXT NOT NULL,
[salt] TEXT,
[hashedPWSalt] TEXT
2021-01-04 05:16:58 +00:00
);
CREATE TABLE IF NOT EXISTS [MediaItems] (
2021-01-04 06:55:41 +00:00
[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,
2021-01-04 05:16:58 +00:00
FOREIGN KEY (userID) REFERENCES Users(userID)
);
CREATE TABLE IF NOT EXISTS [Tags] (
2021-01-04 06:55:41 +00:00
[tagID] INTEGER PRIMARY KEY,
2021-01-04 05:16:58 +00:00
[name] TEXT NOT NULL
);
CREATE TABLE IF NOT EXISTS [MediaTags] (
2021-01-04 06:55:41 +00:00
[mediaID] INTEGER NOT NULL,
[tagID] INTEGER NOT NULL,
2021-01-04 05:16:58 +00:00
FOREIGN KEY (mediaID) REFERENCES MediaItems(mediaID)
FOREIGN KEY (tagID) REFERENCES Tags(tagID)
);
CREATE TABLE IF NOT EXISTS [Albums] (
2021-01-04 06:55:41 +00:00
[albumID] INTEGER PRIMARY KEY,
2021-01-04 05:16:58 +00:00
[userID] INTEGER NOT NULL,
[name] TEXT NOT NULL,
FOREIGN KEY (userID) REFERENCES Users(userID)
);
CREATE TABLE IF NOT EXISTS [MediaAlbums] (
2021-01-04 06:55:41 +00:00
[mediaID] INTEGER NOT NULL,
[albumID] INTEGER NOT NULL,
2021-01-04 05:16:58 +00:00
FOREIGN KEY (mediaID) REFERENCES MediaItems(mediaID)
FOREIGN KEY (albumID) REFERENCES Albums(albumID)
);