add db connection, refactor code, add db migration files
This commit is contained in:
2
db/migrations/000001_create_foundry_state.down.sql
Normal file
2
db/migrations/000001_create_foundry_state.down.sql
Normal file
@@ -0,0 +1,2 @@
|
||||
DROP TABLE IF EXISTS options;
|
||||
DROP TABLE IF EXISTS foundry_state;
|
||||
15
db/migrations/000001_create_foundry_state.up.sql
Normal file
15
db/migrations/000001_create_foundry_state.up.sql
Normal file
@@ -0,0 +1,15 @@
|
||||
CREATE TABLE IF NOT EXISTS foundry_state (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
is_admin BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
is_setup BOOLEAN NOT NULL DEFAULT TRUE,
|
||||
state_type INTEGER NOT NULL,
|
||||
|
||||
created_at DATETIME NOT NULL DEFAULT current_timestamp
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS options (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
state_id INTEGER UNIQUE,
|
||||
lang TEXT NOT NULL,
|
||||
FOREIGN KEY (state_id) REFERENCES foundry_state(id) ON DELETE CASCADE
|
||||
);
|
||||
3
db/migrations/000002_create_modules.down.sql
Normal file
3
db/migrations/000002_create_modules.down.sql
Normal file
@@ -0,0 +1,3 @@
|
||||
DROP TABLE IF EXISTS modules_languages;
|
||||
DROP TABLE IF EXISTS modules_compatibility;
|
||||
DROP TABLE IF EXISTS modules;
|
||||
31
db/migrations/000002_create_modules.up.sql
Normal file
31
db/migrations/000002_create_modules.up.sql
Normal file
@@ -0,0 +1,31 @@
|
||||
CREATE TABLE IF NOT EXISTS modules (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
text_id VARCHAR(256) NOT NULL,
|
||||
title VARCHAR(256) NOT NULL,
|
||||
description TEXT NOT NULL,
|
||||
url VARCHAR(256) NOT NULL,
|
||||
version VARCHAR(64) NOT NULL,
|
||||
availability INTEGER NOT NULL,
|
||||
|
||||
created_at DATETIME NOT NULL DEFAULT current_timestamp
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS modules_compatibility (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
model_id INTEGER UNIQUE,
|
||||
minimum VARCHAR(64) NOT NULL,
|
||||
verified VARCHAR(64) NOT NULL,
|
||||
maximum VARCHAR(64) NOT NULL,
|
||||
|
||||
FOREIGN KEY (model_id) REFERENCES modules(id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS modules_languages (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
model_id INTEGER,
|
||||
language VARCHAR(256) NOT NULL,
|
||||
name VARCHAR(256) NOT NULL,
|
||||
path VARCHAR(256) NOT NULL,
|
||||
|
||||
FOREIGN KEY (model_id) REFERENCES modules(id) ON DELETE CASCADE
|
||||
);
|
||||
2
db/migrations/000003_create_systems.down.sql
Normal file
2
db/migrations/000003_create_systems.down.sql
Normal file
@@ -0,0 +1,2 @@
|
||||
DROP TABLE IF EXISTS systems_compatibility;
|
||||
DROP TABLE IF EXISTS systems;
|
||||
20
db/migrations/000003_create_systems.up.sql
Normal file
20
db/migrations/000003_create_systems.up.sql
Normal file
@@ -0,0 +1,20 @@
|
||||
CREATE TABLE IF NOT EXISTS systems (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
text_id VARCHAR(256) NOT NULL,
|
||||
title VARCHAR(256) NOT NULL,
|
||||
description TEXT NOT NULL,
|
||||
url VARCHAR(256) NOT NULL,
|
||||
download VARCHAR(256) NOT NULL,
|
||||
|
||||
created_at DATETIME NOT NULL DEFAULT current_timestamp
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS systems_compatibility (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
system_id INTEGER UNIQUE,
|
||||
minimum VARCHAR(64) NOT NULL,
|
||||
verified VARCHAR(64) NOT NULL,
|
||||
maximum VARCHAR(64) NOT NULL,
|
||||
|
||||
FOREIGN KEY (system_id) REFERENCES systems(id) ON DELETE CASCADE
|
||||
);
|
||||
2
db/migrations/000004_create_worlds.down.sql
Normal file
2
db/migrations/000004_create_worlds.down.sql
Normal file
@@ -0,0 +1,2 @@
|
||||
DROP TABLE IF EXISTS worlds_compatibility;
|
||||
DROP TABLE IF EXISTS worlds;
|
||||
23
db/migrations/000004_create_worlds.up.sql
Normal file
23
db/migrations/000004_create_worlds.up.sql
Normal file
@@ -0,0 +1,23 @@
|
||||
CREATE TABLE IF NOT EXISTS worlds (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
text_id VARCHAR(256) NOT NULL,
|
||||
title VARCHAR(256) NOT NULL,
|
||||
description TEXT NOT NULL,
|
||||
system VARCHAR(256) NOT NULL,
|
||||
core_version VARCHAR(256) NOT NULL,
|
||||
system_version VARCHAR(256) NOT NULL,
|
||||
playtime INTEGER NOT NULL,
|
||||
next_session DATETIME NOT NULL,
|
||||
|
||||
created_at DATETIME NOT NULL DEFAULT current_timestamp
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS worlds_compatibility (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
world_id INTEGER UNIQUE,
|
||||
minimum VARCHAR(64) NOT NULL,
|
||||
verified VARCHAR(64) NOT NULL,
|
||||
maximum VARCHAR(64) NOT NULL,
|
||||
|
||||
FOREIGN KEY (world_id) REFERENCES worlds(id) ON DELETE CASCADE
|
||||
);
|
||||
3
db/migrations/000005_create_users.down.sql
Normal file
3
db/migrations/000005_create_users.down.sql
Normal file
@@ -0,0 +1,3 @@
|
||||
DROP TABLE IF EXISTS users;
|
||||
DROP TABLE IF EXISTS users_hotbar;
|
||||
DROP TABLE IF EXISTS users_stats;
|
||||
32
db/migrations/000005_create_users.up.sql
Normal file
32
db/migrations/000005_create_users.up.sql
Normal file
@@ -0,0 +1,32 @@
|
||||
CREATE TABLE IF NOT EXISTS users (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
name VARCHAR(256) NOT NULL,
|
||||
role INTEGER NOT NULL,
|
||||
character VARCHAR(128) NOT NULL,
|
||||
color VARCHAR(128) NOT NULL,
|
||||
pronouns VARCHAR(128) NOT NULL,
|
||||
|
||||
created_at DATETIME NOT NULL DEFAULT current_timestamp
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS users_hotbar (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
user_id INTEGER,
|
||||
key TEXT NOT NULL,
|
||||
value TEXT NOT NULL,
|
||||
|
||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS users_stats (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
user_id INTEGER,
|
||||
core_version TEXT NOT NULL,
|
||||
system_id VARCHAR(64) NOT NULL,
|
||||
system_version VARCHAR(64) NOT NULL,
|
||||
created_time INTEGER NOT NULL,
|
||||
modified_time INTEGER NOT NULL,
|
||||
last_modified_by VARCHAR(256) NOT NULL,
|
||||
|
||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
||||
);
|
||||
Reference in New Issue
Block a user