Skip to content

Commit 231ba87

Browse files
committed
test: [#56] WIP. scaffolding to test upgrader command
1 parent 439079b commit 231ba87

12 files changed

+128
-0
lines changed

tests/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
mod databases;
2+
pub mod upgrades;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CREATE TABLE IF NOT EXISTS torrust_users (
2+
user_id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
3+
username VARCHAR(32) NOT NULL UNIQUE,
4+
email VARCHAR(100) NOT NULL UNIQUE,
5+
email_verified BOOLEAN NOT NULL DEFAULT FALSE,
6+
password TEXT NOT NULL
7+
)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CREATE TABLE IF NOT EXISTS torrust_tracker_keys (
2+
key_id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
3+
user_id INTEGER,
4+
key VARCHAR(32) NOT NULL,
5+
valid_until INT(10) NOT NULL,
6+
FOREIGN KEY(user_id) REFERENCES torrust_users(user_id)
7+
)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CREATE TABLE torrust_categories (
2+
category_id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
3+
name VARCHAR(64) NOT NULL UNIQUE
4+
);
5+
6+
INSERT INTO torrust_categories (name) VALUES
7+
('movies'), ('tv shows'), ('games'), ('music'), ('software');
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CREATE TABLE IF NOT EXISTS torrust_torrent_files (
2+
file_id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
3+
torrent_id INTEGER NOT NULL,
4+
number INTEGER NOT NULL,
5+
path VARCHAR(255) NOT NULL,
6+
length INTEGER NOT NULL,
7+
FOREIGN KEY(torrent_id) REFERENCES torrust_torrents(torrent_id)
8+
)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE torrust_users
2+
ADD COLUMN administrator BOOLEAN NOT NULL DEFAULT FALSE;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
CREATE TABLE IF NOT EXISTS torrust_torrents (
2+
torrent_id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
3+
uploader VARCHAR(32) NOT NULL,
4+
info_hash VARCHAR(20) UNIQUE NOT NULL,
5+
title VARCHAR(256) UNIQUE NOT NULL,
6+
category_id INTEGER NOT NULL,
7+
description TEXT,
8+
upload_date INT(10) NOT NULL,
9+
file_size BIGINT NOT NULL,
10+
seeders INTEGER NOT NULL,
11+
leechers INTEGER NOT NULL,
12+
FOREIGN KEY(uploader) REFERENCES torrust_users(username) ON DELETE CASCADE,
13+
FOREIGN KEY(category_id) REFERENCES torrust_categories(category_id) ON DELETE CASCADE
14+
)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE torrust_categories
2+
ADD COLUMN icon VARCHAR(32);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub mod tests;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.db

0 commit comments

Comments
 (0)