finish setup insert method, refactor sql migration file
This commit is contained in:
@@ -1,2 +0,0 @@
|
|||||||
DROP TABLE IF EXISTS options;
|
|
||||||
DROP TABLE IF EXISTS foundry_state;
|
|
||||||
38
db/migrations/000001_create_setup.down.sql
Normal file
38
db/migrations/000001_create_setup.down.sql
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
DROP TABLE IF EXISTS folder;
|
||||||
|
DROP TABLE IF EXISTS pack;
|
||||||
|
DROP TABLE IF EXISTS language;
|
||||||
|
DROP TABLE IF EXISTS style;
|
||||||
|
DROP TABLE IF EXISTS media;
|
||||||
|
DROP TABLE IF EXISTS author;
|
||||||
|
DROP TABLE IF EXISTS es_modules;
|
||||||
|
DROP TABLE IF EXISTS scripts;
|
||||||
|
DROP TABLE IF EXISTS tags;
|
||||||
|
DROP TABLE IF EXISTS relationships;
|
||||||
|
DROP TABLE IF EXISTS compatibility;
|
||||||
|
DROP TABLE IF EXISTS world;
|
||||||
|
DROP TABLE IF EXISTS grid;
|
||||||
|
DROP TABLE IF EXISTS system;
|
||||||
|
DROP TABLE IF EXISTS package_warnings_data_error;
|
||||||
|
DROP TABLE IF EXISTS package_warnings_data_warning;
|
||||||
|
DROP TABLE IF EXISTS package_warnings_data;
|
||||||
|
DROP TABLE IF EXISTS package_warnings;
|
||||||
|
DROP TABLE IF EXISTS news;
|
||||||
|
DROP TABLE IF EXISTS folder_packs;
|
||||||
|
DROP TABLE IF EXISTS folder;
|
||||||
|
DROP TABLE IF EXISTS pack_folder;
|
||||||
|
DROP TABLE IF EXISTS index_;
|
||||||
|
DROP TABLE IF EXISTS ownership;
|
||||||
|
DROP TABLE IF EXISTS relationships_data;
|
||||||
|
DROP TABLE IF EXISTS document_types_data_html;
|
||||||
|
DROP TABLE IF EXISTS document_types_data;
|
||||||
|
DROP TABLE IF EXISTS document_types;
|
||||||
|
DROP TABLE IF EXISTS module;
|
||||||
|
DROP TABLE IF EXISTS setup_language_module;
|
||||||
|
DROP TABLE IF EXISTS setup_language;
|
||||||
|
DROP TABLE IF EXISTS release_;
|
||||||
|
DROP TABLE IF EXISTS setup_options;
|
||||||
|
DROP TABLE IF EXISTS files_storage;
|
||||||
|
DROP TABLE IF EXISTS files;
|
||||||
|
DROP TABLE IF EXISTS featured_content;
|
||||||
|
DROP TABLE IF EXISTS core_update;
|
||||||
|
DROP TABLE IF EXISTS setup;
|
||||||
526
db/migrations/000001_create_setup.up.sql
Normal file
526
db/migrations/000001_create_setup.up.sql
Normal file
@@ -0,0 +1,526 @@
|
|||||||
|
CREATE TABLE IF NOT EXISTS setup (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
|
||||||
|
is_admin BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
|
is_setup BOOLEAN NOT NULL DEFAULT TRUE,
|
||||||
|
|
||||||
|
created_at DATETIME NOT NULL DEFAULT current_timestamp
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS core_update (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
|
||||||
|
has_update BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
|
can_update BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
|
could_reach_website BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
|
slow_response BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
|
will_disable_modules BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
|
version VARCHAR(64) NOT NULL,
|
||||||
|
channel VARCHAR(64) NOT NULL,
|
||||||
|
|
||||||
|
setup_id INTEGER UNIQUE,
|
||||||
|
FOREIGN KEY (setup_id) REFERENCES setup(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS featured_content (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
|
||||||
|
title VARCHAR(128) NOT NULL,
|
||||||
|
caption VARCHAR(128) NOT NULL,
|
||||||
|
url VARCHAR(128) NOT NULL,
|
||||||
|
image VARCHAR(128) NOT NULL,
|
||||||
|
|
||||||
|
setup_id INTEGER UNIQUE,
|
||||||
|
FOREIGN KEY (setup_id) REFERENCES setup(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS files (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
|
||||||
|
setup_id INTEGER UNIQUE,
|
||||||
|
FOREIGN KEY (setup_id) REFERENCES setup(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS files_storage (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
|
||||||
|
storage TEXT NOT NULL,
|
||||||
|
|
||||||
|
files_id INTEGER,
|
||||||
|
FOREIGN KEY (files_id) REFERENCES files(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS setup_options (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
|
||||||
|
css_theme VARCHAR(128) NOT NULL,
|
||||||
|
data_path VARCHAR(128) NOT NULL,
|
||||||
|
hostname VARCHAR(128) NOT NULL,
|
||||||
|
language VARCHAR(128) NOT NULL,
|
||||||
|
local_hostname VARCHAR(128) NOT NULL,
|
||||||
|
update_channel VARCHAR(128) NOT NULL,
|
||||||
|
port INTEGER NOT NULL,
|
||||||
|
compress_socket BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
|
compress_static BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
|
fullscreen BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
|
hot_reload BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
|
proxy_ssl BOOLEAN NOT NULL,
|
||||||
|
telemetry BOOLEAN NOT NULL,
|
||||||
|
upnp BOOLEAN NOT NULL,
|
||||||
|
delete_nedb BOOLEAN NOT NULL,
|
||||||
|
no_backups BOOLEAN NOT NULL,
|
||||||
|
|
||||||
|
setup_id INTEGER UNIQUE,
|
||||||
|
FOREIGN KEY (setup_id) REFERENCES setup(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS release_ (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
|
||||||
|
generation INTEGER NOT NULL,
|
||||||
|
build INTEGER NOT NULL,
|
||||||
|
node_version INTEGER NOT NULL,
|
||||||
|
max_generation INTEGER NOT NULL,
|
||||||
|
max_stable_generation INTEGER NOT NULL,
|
||||||
|
time DATETIME NOT NULL,
|
||||||
|
channel VARCHAR(128) NOT NULL,
|
||||||
|
suffix VARCHAR(128) NOT NULL,
|
||||||
|
|
||||||
|
setup_id INTEGER UNIQUE,
|
||||||
|
FOREIGN KEY (setup_id) REFERENCES setup(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS setup_language (
|
||||||
|
id INTEGER PRIMARY KEY,
|
||||||
|
|
||||||
|
label VARCHAR(128) NOT NULL,
|
||||||
|
|
||||||
|
setup_id INTEGER,
|
||||||
|
FOREIGN KEY (setup_id) REFERENCES setup(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS setup_language_module (
|
||||||
|
id TEXT PRIMARY KEY,
|
||||||
|
|
||||||
|
label VARCHAR(128) NOT NULL,
|
||||||
|
path VARCHAR(128) NOT NULL,
|
||||||
|
|
||||||
|
setup_language_id INTEGER,
|
||||||
|
FOREIGN KEY (setup_language_id) REFERENCES setup_language(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS module (
|
||||||
|
id TEXT PRIMARY KEY,
|
||||||
|
|
||||||
|
title VARCHAR(128) NOT NULL,
|
||||||
|
description VARCHAR(128) NOT NULL,
|
||||||
|
url VARCHAR(128) NOT NULL,
|
||||||
|
license VARCHAR(128) NOT NULL,
|
||||||
|
readme VARCHAR(128) NOT NULL,
|
||||||
|
bugs VARCHAR(128) NOT NULL,
|
||||||
|
changelog VARCHAR(128) NOT NULL,
|
||||||
|
version VARCHAR(128) NOT NULL,
|
||||||
|
manifest VARCHAR(128) NOT NULL,
|
||||||
|
download VARCHAR(128) NOT NULL,
|
||||||
|
socket BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
|
protected BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
|
exclusive_ BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
|
persistent_storage BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
|
core_translation BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
|
library BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
|
locked BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
|
owned BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
|
has_storage BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
|
active BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
|
availability INTEGER NOT NULL DEFAULT FALSE,
|
||||||
|
|
||||||
|
setup_id INTEGER,
|
||||||
|
FOREIGN KEY (setup_id) REFERENCES setup(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS document_types (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
|
||||||
|
module_id TEXT UNIQUE,
|
||||||
|
FOREIGN KEY (module_id) REFERENCES module(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS document_types_data (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
|
||||||
|
type VARCHAR(64) NOT NULL,
|
||||||
|
|
||||||
|
document_types_id INTEGER,
|
||||||
|
FOREIGN KEY (document_types_id) REFERENCES document_types(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS document_types_data_html (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
|
||||||
|
value TEXT NOT NULL,
|
||||||
|
|
||||||
|
document_types_data_id INTEGER,
|
||||||
|
FOREIGN KEY (document_types_data_id) REFERENCES document_types_data(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS relationships (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
|
||||||
|
module_id TEXT UNIQUE,
|
||||||
|
FOREIGN KEY (module_id) REFERENCES module(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS relationships_systems (
|
||||||
|
id TEXT PRIMARY KEY,
|
||||||
|
|
||||||
|
relationships_type VARCHAR(32) NOT NULL,
|
||||||
|
type TEXT NOT NULL,
|
||||||
|
manifest TEXT NOT NULL,
|
||||||
|
|
||||||
|
relationships_id INTEGER,
|
||||||
|
FOREIGN KEY (relationships_id) REFERENCES relationships(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS relationships_requires (
|
||||||
|
id TEXT PRIMARY KEY,
|
||||||
|
|
||||||
|
relationships_type VARCHAR(32) NOT NULL,
|
||||||
|
type TEXT NOT NULL,
|
||||||
|
manifest TEXT NOT NULL,
|
||||||
|
|
||||||
|
relationships_id INTEGER,
|
||||||
|
FOREIGN KEY (relationships_id) REFERENCES relationships(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS relationships_recommends (
|
||||||
|
id TEXT PRIMARY KEY,
|
||||||
|
|
||||||
|
relationships_type VARCHAR(32) NOT NULL,
|
||||||
|
type TEXT NOT NULL,
|
||||||
|
manifest TEXT NOT NULL,
|
||||||
|
|
||||||
|
relationships_id INTEGER,
|
||||||
|
FOREIGN KEY (relationships_id) REFERENCES relationships(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS relationships_conflicts (
|
||||||
|
id TEXT PRIMARY KEY,
|
||||||
|
|
||||||
|
relationships_type VARCHAR(32) NOT NULL,
|
||||||
|
type TEXT NOT NULL,
|
||||||
|
manifest TEXT NOT NULL,
|
||||||
|
|
||||||
|
relationships_id INTEGER,
|
||||||
|
FOREIGN KEY (relationships_id) REFERENCES relationships(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS compatibility (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
|
||||||
|
minimum VARCHAR(64) NOT NULL,
|
||||||
|
verified VARCHAR(64) NOT NULL,
|
||||||
|
maximum VARCHAR(64) NOT NULL,
|
||||||
|
|
||||||
|
module_id TEXT UNIQUE,
|
||||||
|
FOREIGN KEY (module_id) REFERENCES module(id) ON DELETE CASCADE,
|
||||||
|
relationships_systems_id TEXT UNIQUE,
|
||||||
|
FOREIGN KEY (relationships_systems_id) REFERENCES relationships_systems(id) ON DELETE CASCADE
|
||||||
|
relationships_requires_id TEXT UNIQUE,
|
||||||
|
FOREIGN KEY (relationships_requires_id) REFERENCES relationships_requires(id) ON DELETE CASCADE
|
||||||
|
relationships_recommends_id TEXT UNIQUE,
|
||||||
|
FOREIGN KEY (relationships_recommends_id) REFERENCES relationships_recommends(id) ON DELETE CASCADE
|
||||||
|
relationships_conflicts_id TEXT UNIQUE,
|
||||||
|
FOREIGN KEY (relationships_conflicts_id) REFERENCES relationships_conflicts(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS scripts (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
|
||||||
|
value TEXT NOT NULL,
|
||||||
|
|
||||||
|
module_id TEXT,
|
||||||
|
FOREIGN KEY (module_id) REFERENCES module(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS es_modules (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
|
||||||
|
value TEXT NOT NULL,
|
||||||
|
|
||||||
|
module_id TEXT,
|
||||||
|
FOREIGN KEY (module_id) REFERENCES module(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS tags (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
|
||||||
|
value VARCHAR(128) NOT NULL,
|
||||||
|
|
||||||
|
module_id TEXT,
|
||||||
|
FOREIGN KEY (module_id) REFERENCES module(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS author (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
|
||||||
|
name VARCHAR(128) NOT NULL,
|
||||||
|
url VARCHAR(128) NOT NULL,
|
||||||
|
email VARCHAR(128) NOT NULL,
|
||||||
|
discord VARCHAR(128) NOT NULL,
|
||||||
|
|
||||||
|
module_id TEXT,
|
||||||
|
FOREIGN KEY (module_id) REFERENCES module(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS media (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
|
||||||
|
type VARCHAR(128) NOT NULL,
|
||||||
|
url VARCHAR(128) NOT NULL,
|
||||||
|
caption VARCHAR(128) NOT NULL,
|
||||||
|
|
||||||
|
module_id TEXT,
|
||||||
|
FOREIGN KEY (module_id) REFERENCES module(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS style (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
|
||||||
|
src VARCHAR(128) NOT NULL,
|
||||||
|
|
||||||
|
module_id TEXT,
|
||||||
|
FOREIGN KEY (module_id) REFERENCES module(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS language (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
|
||||||
|
lang VARCHAR(128) NOT NULL,
|
||||||
|
name VARCHAR(128) NOT NULL,
|
||||||
|
path VARCHAR(128) NOT NULL,
|
||||||
|
|
||||||
|
module_id TEXT,
|
||||||
|
FOREIGN KEY (module_id) REFERENCES module(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS pack (
|
||||||
|
id TEXT PRIMARY KEY,
|
||||||
|
|
||||||
|
name VARCHAR(128) NOT NULL,
|
||||||
|
label VARCHAR(128) NOT NULL,
|
||||||
|
banner VARCHAR(128) NOT NULL,
|
||||||
|
path VARCHAR(128) NOT NULL,
|
||||||
|
type VARCHAR(128) NOT NULL,
|
||||||
|
system VARCHAR(128) NOT NULL,
|
||||||
|
package_type VARCHAR(128) NOT NULL,
|
||||||
|
package_name VARCHAR(128) NOT NULL,
|
||||||
|
|
||||||
|
module_id TEXT,
|
||||||
|
FOREIGN KEY (module_id) REFERENCES module(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS ownership (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
|
||||||
|
player VARCHAR(128) NOT NULL,
|
||||||
|
trusted VARCHAR(128) NOT NULL,
|
||||||
|
assistant VARCHAR(128) NOT NULL,
|
||||||
|
|
||||||
|
pack_id TEXT UNIQUE,
|
||||||
|
FOREIGN KEY (pack_id) REFERENCES pack(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS index_ (
|
||||||
|
id TEXT PRIMARY KEY,
|
||||||
|
|
||||||
|
folder VARCHAR(128) NOT NULL,
|
||||||
|
img VARCHAR(128) NOT NULL,
|
||||||
|
name VARCHAR(128) NOT NULL,
|
||||||
|
type VARCHAR(128) NOT NULL,
|
||||||
|
|
||||||
|
pack_id TEXT,
|
||||||
|
FOREIGN KEY (pack_id) REFERENCES pack(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS pack_folder (
|
||||||
|
id TEXT PRIMARY KEY,
|
||||||
|
|
||||||
|
description VARCHAR(128) NOT NULL,
|
||||||
|
name VARCHAR(128) NOT NULL,
|
||||||
|
sorting VARCHAR(128) NOT NULL,
|
||||||
|
type VARCHAR(128) NOT NULL,
|
||||||
|
sort INTEGER NOT NULL,
|
||||||
|
|
||||||
|
pack_id TEXT,
|
||||||
|
FOREIGN KEY (pack_id) REFERENCES pack(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS folder (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
|
||||||
|
name VARCHAR(128) NOT NULL,
|
||||||
|
sorting VARCHAR(128) NOT NULL,
|
||||||
|
color VARCHAR(128) NOT NULL,
|
||||||
|
|
||||||
|
folder_id INTEGER,
|
||||||
|
FOREIGN KEY (folder_id) REFERENCES folder(id) ON DELETE CASCADE,
|
||||||
|
module_id TEXT,
|
||||||
|
FOREIGN KEY (module_id) REFERENCES module(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS folder_packs (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
|
||||||
|
packs VARCHAR(128) NOT NULL,
|
||||||
|
|
||||||
|
folder_id INTEGER,
|
||||||
|
FOREIGN KEY (folder_id) REFERENCES folder(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS news (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
|
||||||
|
title VARCHAR(64) NOT NULL,
|
||||||
|
caption VARCHAR(64) NOT NULL,
|
||||||
|
url VARCHAR(64) NOT NULL,
|
||||||
|
image VARCHAR(64) NOT NULL,
|
||||||
|
|
||||||
|
setup_id INTEGER,
|
||||||
|
FOREIGN KEY (setup_id) REFERENCES setup(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS package_warnings (
|
||||||
|
id TEXT PRIMARY KEY,
|
||||||
|
|
||||||
|
key_ VARCHAR(128) NOT NULL,
|
||||||
|
|
||||||
|
setup_id INTEGER,
|
||||||
|
FOREIGN KEY (setup_id) REFERENCES setup(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS package_warnings_data (
|
||||||
|
id TEXT PRIMARY KEY,
|
||||||
|
|
||||||
|
type VARCHAR(128) NOT NULL,
|
||||||
|
manifest VARCHAR(128) NOT NULL,
|
||||||
|
reinstallable BOOLEAN NOT NULL,
|
||||||
|
|
||||||
|
package_warnings_id TEXT,
|
||||||
|
FOREIGN KEY (package_warnings_id) REFERENCES package_warnings(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS package_warnings_data_warning (
|
||||||
|
id INTEGER PRIMARY KEY,
|
||||||
|
|
||||||
|
value VARCHAR(128) NOT NULL,
|
||||||
|
|
||||||
|
package_warnings_data_id TEXT,
|
||||||
|
FOREIGN KEY (package_warnings_data_id) REFERENCES package_warnings_data(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS package_warnings_data_error (
|
||||||
|
id INTEGER PRIMARY KEY,
|
||||||
|
|
||||||
|
value VARCHAR(128) NOT NULL,
|
||||||
|
|
||||||
|
package_warnings_data_id TEXT,
|
||||||
|
FOREIGN KEY (package_warnings_data_id) REFERENCES package_warnings_data(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS system (
|
||||||
|
id TEXT PRIMARY KEY,
|
||||||
|
|
||||||
|
title VARCHAR(128) NOT NULL,
|
||||||
|
description VARCHAR(128) NOT NULL,
|
||||||
|
url VARCHAR(128) NOT NULL,
|
||||||
|
license VARCHAR(128) NOT NULL,
|
||||||
|
bugs VARCHAR(128) NOT NULL,
|
||||||
|
changelog VARCHAR(128) NOT NULL,
|
||||||
|
version VARCHAR(128) NOT NULL,
|
||||||
|
manifest VARCHAR(128) NOT NULL,
|
||||||
|
download VARCHAR(128) NOT NULL,
|
||||||
|
background VARCHAR(128) NOT NULL DEFAULT FALSE,
|
||||||
|
primary_token_attribute VARCHAR(128) NOT NULL DEFAULT FALSE,
|
||||||
|
availability INTEGER NOT NULL DEFAULT FALSE,
|
||||||
|
socket BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
|
protected BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
|
exclusive_ BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
|
persistent_storage BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
|
locked BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
|
owned BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
|
has_storage BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
|
|
||||||
|
setup_id INTEGER,
|
||||||
|
FOREIGN KEY (setup_id) REFERENCES setup(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
ALTER TABLE compatibility ADD COLUMN system_id TEXT UNIQUE REFERENCES system(id);
|
||||||
|
ALTER TABLE relationships ADD COLUMN system_id TEXT UNIQUE REFERENCES system(id);
|
||||||
|
ALTER TABLE document_types ADD COLUMN system_id TEXT UNIQUE REFERENCES system(id);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS grid (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
|
||||||
|
type INTEGER NOT NULL,
|
||||||
|
size INTEGER NOT NULL,
|
||||||
|
distance INTEGER NOT NULL,
|
||||||
|
diagonals INTEGER NOT NULL,
|
||||||
|
thickness INTEGER NOT NULL,
|
||||||
|
alpha REAL NOT NULL,
|
||||||
|
color VARCHAR(128) NOT NULL,
|
||||||
|
units VARCHAR(128) NOT NULL,
|
||||||
|
style VARCHAR(128) NOT NULL,
|
||||||
|
|
||||||
|
system_id TEXT UNIQUE,
|
||||||
|
FOREIGN KEY (system_id) REFERENCES system(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
ALTER TABLE es_modules ADD COLUMN system_id TEXT REFERENCES system(id);
|
||||||
|
ALTER TABLE scripts ADD COLUMN system_id TEXT REFERENCES system(id);
|
||||||
|
ALTER TABLE tags ADD COLUMN system_id TEXT REFERENCES system(id);
|
||||||
|
ALTER TABLE author ADD COLUMN system_id TEXT REFERENCES system(id);
|
||||||
|
ALTER TABLE media ADD COLUMN system_id TEXT REFERENCES system(id);
|
||||||
|
ALTER TABLE pack ADD COLUMN system_id TEXT REFERENCES system(id);
|
||||||
|
ALTER TABLE style ADD COLUMN system_id TEXT REFERENCES system(id);
|
||||||
|
ALTER TABLE language ADD COLUMN system_id TEXT REFERENCES system(id);
|
||||||
|
ALTER TABLE folder ADD COLUMN system_id TEXT REFERENCES system(id);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS world (
|
||||||
|
id TEXT PRIMARY KEY,
|
||||||
|
|
||||||
|
title VARCHAR(128) NOT NULL,
|
||||||
|
description VARCHAR(128) NOT NULL,
|
||||||
|
version VARCHAR(128) NOT NULL,
|
||||||
|
system VARCHAR(128) NOT NULL,
|
||||||
|
background VARCHAR(128) NOT NULL,
|
||||||
|
join_theme VARCHAR(128) NOT NULL,
|
||||||
|
core_version VARCHAR(128) NOT NULL,
|
||||||
|
system_version VARCHAR(128) NOT NULL,
|
||||||
|
last_played VARCHAR(128) NOT NULL,
|
||||||
|
playtime INTEGER NOT NULL,
|
||||||
|
availability INTEGER NOT NULL,
|
||||||
|
next_session DATETIME NOT NULL,
|
||||||
|
socket BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
|
protected BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
|
exclusive_ BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
|
persistent_storage BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
|
locked BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
|
owned BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
|
has_storage BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
|
|
||||||
|
setup_id INTEGER,
|
||||||
|
FOREIGN KEY (setup_id) REFERENCES setup(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
ALTER TABLE compatibility ADD COLUMN world_id TEXT UNIQUE REFERENCES world(id);
|
||||||
|
ALTER TABLE relationships ADD COLUMN world_id TEXT UNIQUE REFERENCES world(id);
|
||||||
|
|
||||||
|
ALTER TABLE tags ADD COLUMN world_id TEXT REFERENCES world(id);
|
||||||
|
ALTER TABLE scripts ADD COLUMN world_id TEXT REFERENCES world(id);
|
||||||
|
ALTER TABLE es_modules ADD COLUMN world_id TEXT REFERENCES world(id);
|
||||||
|
ALTER TABLE author ADD COLUMN world_id TEXT REFERENCES world(id);
|
||||||
|
ALTER TABLE media ADD COLUMN world_id TEXT REFERENCES world(id);
|
||||||
|
ALTER TABLE style ADD COLUMN world_id TEXT REFERENCES world(id);
|
||||||
|
ALTER TABLE language ADD COLUMN world_id TEXT REFERENCES world(id);
|
||||||
|
ALTER TABLE pack ADD COLUMN world_id TEXT REFERENCES world(id);
|
||||||
|
ALTER TABLE folder ADD COLUMN world_id TEXT REFERENCES world(id);
|
||||||
@@ -1,12 +1,3 @@
|
|||||||
CREATE TABLE IF NOT EXISTS setup (
|
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
|
|
||||||
is_admin BOOLEAN NOT NULL DEFAULT FALSE,
|
|
||||||
is_setup BOOLEAN NOT NULL DEFAULT TRUE,
|
|
||||||
|
|
||||||
created_at DATETIME NOT NULL DEFAULT current_timestamp
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS game (
|
CREATE TABLE IF NOT EXISTS game (
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT
|
id INTEGER PRIMARY KEY AUTOINCREMENT
|
||||||
|
|
||||||
@@ -18,96 +9,6 @@ CREATE TABLE IF NOT EXISTS game (
|
|||||||
created_at DATETIME NOT NULL DEFAULT current_timestamp
|
created_at DATETIME NOT NULL DEFAULT current_timestamp
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS world (
|
|
||||||
id TEXT PRIMARY KEY,
|
|
||||||
|
|
||||||
socket BOOLEAN NOT NULL DEFAULT FALSE,
|
|
||||||
protected BOOLEAN NOT NULL DEFAULT FALSE,
|
|
||||||
exclusive_ BOOLEAN NOT NULL DEFAULT FALSE,
|
|
||||||
persistent_storage BOOLEAN NOT NULL DEFAULT FALSE,
|
|
||||||
locked BOOLEAN NOT NULL DEFAULT FALSE,
|
|
||||||
owned BOOLEAN NOT NULL DEFAULT FALSE,
|
|
||||||
has_storage BOOLEAN NOT NULL DEFAULT FALSE,
|
|
||||||
playtime INTEGER NOT NULL,
|
|
||||||
availability INTEGER NOT NULL,
|
|
||||||
next_session DATETIME NOT NULL,
|
|
||||||
|
|
||||||
title VARCHAR(128) NOT NULL,
|
|
||||||
description VARCHAR(128) NOT NULL,
|
|
||||||
version VARCHAR(128) NOT NULL,
|
|
||||||
system VARCHAR(128) NOT NULL,
|
|
||||||
background VARCHAR(128) NOT NULL,
|
|
||||||
join_theme VARCHAR(128) NOT NULL,
|
|
||||||
core_version VARCHAR(128) NOT NULL,
|
|
||||||
system_version VARCHAR(128) NOT NULL,
|
|
||||||
last_played VARCHAR(128) NOT NULL,
|
|
||||||
|
|
||||||
setup_id INTEGER,
|
|
||||||
FOREIGN KEY (setup_id) REFERENCES setup(id) ON DELETE CASCADE
|
|
||||||
game_id INTEGER UNIQUE,
|
|
||||||
FOREIGN KEY (game_id) REFERENCES game(id) ON DELETE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS system (
|
|
||||||
id TEXT PRIMARY KEY,
|
|
||||||
|
|
||||||
title VARCHAR(128) NOT NULL,
|
|
||||||
description VARCHAR(128) NOT NULL,
|
|
||||||
url VARCHAR(128) NOT NULL,
|
|
||||||
license VARCHAR(128) NOT NULL,
|
|
||||||
bugs VARCHAR(128) NOT NULL,
|
|
||||||
changelog VARCHAR(128) NOT NULL,
|
|
||||||
version VARCHAR(128) NOT NULL,
|
|
||||||
socket BOOLEAN NOT NULL DEFAULT FALSE,
|
|
||||||
manifest VARCHAR(128) NOT NULL,
|
|
||||||
download VARCHAR(128) NOT NULL,
|
|
||||||
protected BOOLEAN NOT NULL DEFAULT FALSE,
|
|
||||||
exclusive_ BOOLEAN NOT NULL DEFAULT FALSE,
|
|
||||||
persistent_storage BOOLEAN NOT NULL DEFAULT FALSE,
|
|
||||||
background VARCHAR(128) NOT NULL DEFAULT FALSE,
|
|
||||||
primary_token_attribute VARCHAR(128) NOT NULL DEFAULT FALSE,
|
|
||||||
availability INTEGER NOT NULL DEFAULT FALSE,
|
|
||||||
locked BOOLEAN NOT NULL DEFAULT FALSE,
|
|
||||||
owned BOOLEAN NOT NULL DEFAULT FALSE,
|
|
||||||
has_storage BOOLEAN NOT NULL DEFAULT FALSE,
|
|
||||||
|
|
||||||
setup_id INTEGER,
|
|
||||||
FOREIGN KEY (setup_id) REFERENCES setup(id) ON DELETE CASCADE
|
|
||||||
game_id INTEGER UNIQUE,
|
|
||||||
FOREIGN KEY (game_id) REFERENCES game(id) ON DELETE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS module (
|
|
||||||
id TEXT PRIMARY KEY,
|
|
||||||
|
|
||||||
title VARCHAR(128) NOT NULL,
|
|
||||||
description VARCHAR(128) NOT NULL,
|
|
||||||
url VARCHAR(128) NOT NULL,
|
|
||||||
license VARCHAR(128) NOT NULL,
|
|
||||||
readme VARCHAR(128) NOT NULL,
|
|
||||||
bugs VARCHAR(128) NOT NULL,
|
|
||||||
changelog VARCHAR(128) NOT NULL,
|
|
||||||
version VARCHAR(128) NOT NULL,
|
|
||||||
socket BOOLEAN NOT NULL DEFAULT FALSE,
|
|
||||||
manifest VARCHAR(128) NOT NULL,
|
|
||||||
download VARCHAR(128) NOT NULL,
|
|
||||||
protected BOOLEAN NOT NULL DEFAULT FALSE,
|
|
||||||
exclusive_ BOOLEAN NOT NULL DEFAULT FALSE,
|
|
||||||
persistent_storage BOOLEAN NOT NULL DEFAULT FALSE,
|
|
||||||
core_translation BOOLEAN NOT NULL DEFAULT FALSE,
|
|
||||||
library BOOLEAN NOT NULL DEFAULT FALSE,
|
|
||||||
availability INTEGER NOT NULL DEFAULT FALSE,
|
|
||||||
locked BOOLEAN NOT NULL DEFAULT FALSE,
|
|
||||||
owned BOOLEAN NOT NULL DEFAULT FALSE,
|
|
||||||
has_storage BOOLEAN NOT NULL DEFAULT FALSE,
|
|
||||||
active BOOLEAN NOT NULL DEFAULT FALSE,
|
|
||||||
|
|
||||||
setup_id INTEGER,
|
|
||||||
FOREIGN KEY (setup_id) REFERENCES setup(id) ON DELETE CASCADE
|
|
||||||
game_id INTEGER,
|
|
||||||
FOREIGN KEY (game_id) REFERENCES game(id) ON DELETE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS addresses (
|
CREATE TABLE IF NOT EXISTS addresses (
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
|
||||||
@@ -119,29 +20,6 @@ CREATE TABLE IF NOT EXISTS addresses (
|
|||||||
FOREIGN KEY (game_id) REFERENCES game(id) ON DELETE CASCADE
|
FOREIGN KEY (game_id) REFERENCES game(id) ON DELETE CASCADE
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS setup_options (
|
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
|
|
||||||
compress_socket BOOLEAN NOT NULL DEFAULT FALSE,
|
|
||||||
compress_static BOOLEAN NOT NULL DEFAULT FALSE,
|
|
||||||
css_theme VARCHAR(128) NOT NULL,
|
|
||||||
data_path VARCHAR(128) NOT NULL,
|
|
||||||
fullscreen BOOLEAN NOT NULL DEFAULT FALSE,
|
|
||||||
hostname VARCHAR(128) NOT NULL,
|
|
||||||
hot_reload BOOLEAN NOT NULL DEFAULT FALSE,
|
|
||||||
language VARCHAR(128) NOT NULL,
|
|
||||||
local_hostname VARCHAR(128) NOT NULL,
|
|
||||||
port INTEGER NOT NULL,
|
|
||||||
proxy_ssl BOOLEAN NOT NULL,
|
|
||||||
telemetry BOOLEAN NOT NULL,
|
|
||||||
update_channel VARCHAR(128) NOT NULL,
|
|
||||||
upnp BOOLEAN NOT NULL,
|
|
||||||
delete_nedb BOOLEAN NOT NULL,
|
|
||||||
no_backups BOOLEAN NOT NULL,
|
|
||||||
|
|
||||||
setup_id INTEGER UNIQUE,
|
|
||||||
FOREIGN KEY (setup_id) REFERENCES setup(id) ON DELETE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS game_options (
|
CREATE TABLE IF NOT EXISTS game_options (
|
||||||
id INTEGER PRIMARY KEY,
|
id INTEGER PRIMARY KEY,
|
||||||
@@ -483,51 +361,9 @@ CREATE TABLE IF NOT EXISTS active_users (
|
|||||||
FOREIGN KEY (game_id) REFERENCES game(id) ON DELETE CASCADE
|
FOREIGN KEY (game_id) REFERENCES game(id) ON DELETE CASCADE
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS grid (
|
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
|
|
||||||
type INTEGER NOT NULL,
|
|
||||||
size INTEGER NOT NULL,
|
|
||||||
distance INTEGER NOT NULL,
|
|
||||||
diagonals INTEGER NOT NULL,
|
|
||||||
thickness INTEGER NOT NULL,
|
|
||||||
alpha REAL NOT NULL,
|
|
||||||
color VARCHAR(128) NOT NULL,
|
|
||||||
units VARCHAR(128) NOT NULL,
|
|
||||||
style VARCHAR(128) NOT NULL,
|
|
||||||
|
|
||||||
system_id TEXT UNIQUE,
|
|
||||||
FOREIGN KEY (system_id) REFERENCES system(id) ON DELETE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS relationships (
|
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
|
|
||||||
module_id TEXT UNIQUE,
|
|
||||||
FOREIGN KEY (module_id) REFERENCES module(id) ON DELETE CASCADE,
|
|
||||||
system_id TEXT UNIQUE,
|
|
||||||
FOREIGN KEY (system_id) REFERENCES system(id) ON DELETE CASCADE,
|
|
||||||
world_id TEXT UNIQUE,
|
|
||||||
FOREIGN KEY (world_id) REFERENCES world(id) ON DELETE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS release_ (
|
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
|
|
||||||
generation INTEGER NOT NULL,
|
|
||||||
channel VARCHAR(128) NOT NULL,
|
|
||||||
suffix VARCHAR(128) NOT NULL,
|
|
||||||
build INTEGER NOT NULL,
|
|
||||||
node_version INTEGER NOT NULL,
|
|
||||||
max_generation INTEGER NOT NULL,
|
|
||||||
max_stable_generation INTEGER NOT NULL,
|
|
||||||
time INTEGER NOT NULL,
|
|
||||||
|
|
||||||
setup_id INTEGER UNIQUE,
|
|
||||||
FOREIGN KEY (setup_id) REFERENCES setup(id) ON DELETE CASCADE,
|
|
||||||
game_id INTEGER UNIQUE,
|
|
||||||
FOREIGN KEY (game_id) REFERENCES game(id) ON DELETE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS item (
|
CREATE TABLE IF NOT EXISTS item (
|
||||||
id TEXT PRIMARY KEY,
|
id TEXT PRIMARY KEY,
|
||||||
@@ -554,158 +390,6 @@ CREATE TABLE IF NOT EXISTS journal (
|
|||||||
FOREIGN KEY (game_id) REFERENCES game(id) ON DELETE CASCADE
|
FOREIGN KEY (game_id) REFERENCES game(id) ON DELETE CASCADE
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS relationships_data (
|
|
||||||
id TEXT PRIMARY KEY,
|
|
||||||
|
|
||||||
relationships_type VARCHAR(32) NOT NULL,
|
|
||||||
type TEXT NOT NULL,
|
|
||||||
manifest TEXT NOT NULL,
|
|
||||||
|
|
||||||
relationships_id INTEGER UNIQUE,
|
|
||||||
FOREIGN KEY (relationships_id) REFERENCES relationships(id) ON DELETE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS compatibility (
|
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
|
|
||||||
minimum VARCHAR(64) NOT NULL,
|
|
||||||
verified VARCHAR(64) NOT NULL,
|
|
||||||
maximum VARCHAR(64) NOT NULL,
|
|
||||||
|
|
||||||
module_id TEXT UNIQUE,
|
|
||||||
FOREIGN KEY (module_id) REFERENCES module(id) ON DELETE CASCADE,
|
|
||||||
system_id TEXT UNIQUE,
|
|
||||||
FOREIGN KEY (system_id) REFERENCES system(id) ON DELETE CASCADE,
|
|
||||||
world_id TEXT UNIQUE,
|
|
||||||
FOREIGN KEY (world_id) REFERENCES world(id) ON DELETE CASCADE,
|
|
||||||
relationships_data_id TEXT UNIQUE,
|
|
||||||
FOREIGN KEY (relationships_data_id) REFERENCES relationships_data(id) ON DELETE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS author (
|
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
|
|
||||||
name VARCHAR(128) NOT NULL,
|
|
||||||
url VARCHAR(128) NOT NULL,
|
|
||||||
email VARCHAR(128) NOT NULL,
|
|
||||||
discord VARCHAR(128) NOT NULL,
|
|
||||||
|
|
||||||
module_id TEXT,
|
|
||||||
FOREIGN KEY (module_id) REFERENCES module(id) ON DELETE CASCADE,
|
|
||||||
system_id TEXT,
|
|
||||||
FOREIGN KEY (system_id) REFERENCES system(id) ON DELETE CASCADE,
|
|
||||||
world_id TEXT,
|
|
||||||
FOREIGN KEY (world_id) REFERENCES world(id) ON DELETE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS media (
|
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
|
|
||||||
type VARCHAR(128) NOT NULL,
|
|
||||||
url VARCHAR(128) NOT NULL,
|
|
||||||
caption VARCHAR(128) NOT NULL,
|
|
||||||
|
|
||||||
module_id TEXT,
|
|
||||||
FOREIGN KEY (module_id) REFERENCES module(id) ON DELETE CASCADE,
|
|
||||||
system_id TEXT,
|
|
||||||
FOREIGN KEY (system_id) REFERENCES system(id) ON DELETE CASCADE,
|
|
||||||
world_id TEXT,
|
|
||||||
FOREIGN KEY (world_id) REFERENCES world(id) ON DELETE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS scripts (
|
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
|
|
||||||
scripts TEXT NOT NULL,
|
|
||||||
|
|
||||||
module_id TEXT,
|
|
||||||
FOREIGN KEY (module_id) REFERENCES module(id) ON DELETE CASCADE,
|
|
||||||
system_id INTEGER,
|
|
||||||
FOREIGN KEY (system_id) REFERENCES system(id) ON DELETE CASCADE,
|
|
||||||
world_id TEXT,
|
|
||||||
FOREIGN KEY (world_id) REFERENCES world(id) ON DELETE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS es_modules (
|
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
|
|
||||||
es_modules TEXT NOT NULL,
|
|
||||||
|
|
||||||
module_id TEXT,
|
|
||||||
FOREIGN KEY (module_id) REFERENCES module(id) ON DELETE CASCADE,
|
|
||||||
system_id TEXT,
|
|
||||||
FOREIGN KEY (system_id) REFERENCES system(id) ON DELETE CASCADE,
|
|
||||||
world_id TEXT,
|
|
||||||
FOREIGN KEY (world_id) REFERENCES world(id) ON DELETE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS style (
|
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
|
|
||||||
src VARCHAR(128) NOT NULL,
|
|
||||||
|
|
||||||
module_id TEXT,
|
|
||||||
FOREIGN KEY (module_id) REFERENCES module(id) ON DELETE CASCADE,
|
|
||||||
system_id TEXT,
|
|
||||||
FOREIGN KEY (system_id) REFERENCES system(id) ON DELETE CASCADE,
|
|
||||||
world_id TEXT,
|
|
||||||
FOREIGN KEY (world_id) REFERENCES world(id) ON DELETE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS language (
|
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
|
|
||||||
lang VARCHAR(128) NOT NULL,
|
|
||||||
name VARCHAR(128) NOT NULL,
|
|
||||||
path VARCHAR(128) NOT NULL,
|
|
||||||
|
|
||||||
module_id TEXT,
|
|
||||||
FOREIGN KEY (module_id) REFERENCES module(id) ON DELETE CASCADE,
|
|
||||||
system_id TEXT,
|
|
||||||
FOREIGN KEY (system_id) REFERENCES system(id) ON DELETE CASCADE,
|
|
||||||
world_id TEXT,
|
|
||||||
FOREIGN KEY (world_id) REFERENCES world(id) ON DELETE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS package_warnings (
|
|
||||||
id TEXT PRIMARY KEY,
|
|
||||||
|
|
||||||
key_ VARCHAR(128) NOT NULL,
|
|
||||||
|
|
||||||
setup_id INTEGER,
|
|
||||||
FOREIGN KEY (setup_id) REFERENCES setup(id) ON DELETE CASCADE,
|
|
||||||
game_id INTEGER,
|
|
||||||
FOREIGN KEY (game_id) REFERENCES game(id) ON DELETE CASCADE,
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS package_warnings_data (
|
|
||||||
id TEXT PRIMARY KEY,
|
|
||||||
|
|
||||||
type VARCHAR(128) NOT NULL,
|
|
||||||
reinstallable VARCHAR(128) NOT NULL,
|
|
||||||
manifest VARCHAR(128) NOT NULL,
|
|
||||||
|
|
||||||
package_warnings_id TEXT,
|
|
||||||
FOREIGN KEY (package_warnings_id) REFERENCES package_warnings(id) ON DELETE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS package_warnings_data_warning (
|
|
||||||
id INTEGER PRIMARY KEY,
|
|
||||||
|
|
||||||
value VARCHAR(128) NOT NULL,
|
|
||||||
|
|
||||||
package_warnings_data_id TEXT,
|
|
||||||
FOREIGN KEY (package_warnings_data_id) REFERENCES package_warnings_data(id) ON DELETE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS package_warnings_data_error (
|
|
||||||
id INTEGER PRIMARY KEY,
|
|
||||||
|
|
||||||
value VARCHAR(128) NOT NULL,
|
|
||||||
|
|
||||||
package_warnings_data_id TEXT,
|
|
||||||
FOREIGN KEY (package_warnings_data_id) REFERENCES package_warnings_data(id) ON DELETE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS world_folder (
|
CREATE TABLE IF NOT EXISTS world_folder (
|
||||||
id TEXT PRIMARY KEY,
|
id TEXT PRIMARY KEY,
|
||||||
@@ -909,28 +593,6 @@ CREATE TABLE IF NOT EXISTS message_rolls (
|
|||||||
FOREIGN KEY (message_id) REFERENCES message(id) ON DELETE CASCADE
|
FOREIGN KEY (message_id) REFERENCES message(id) ON DELETE CASCADE
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS pack (
|
|
||||||
id TEXT PRIMARY KEY,
|
|
||||||
|
|
||||||
name VARCHAR(128) NOT NULL,
|
|
||||||
label VARCHAR(128) NOT NULL,
|
|
||||||
banner VARCHAR(128) NOT NULL,
|
|
||||||
path VARCHAR(128) NOT NULL,
|
|
||||||
type VARCHAR(128) NOT NULL,
|
|
||||||
system VARCHAR(128) NOT NULL,
|
|
||||||
package_type VARCHAR(128) NOT NULL,
|
|
||||||
package_name VARCHAR(128) NOT NULL,
|
|
||||||
|
|
||||||
game_id INTEGER,
|
|
||||||
FOREIGN KEY (game_id) REFERENCES game(id) ON DELETE CASCADE,
|
|
||||||
module_id TEXT,
|
|
||||||
FOREIGN KEY (module_id) REFERENCES module(id) ON DELETE CASCADE,
|
|
||||||
system_id TEXT,
|
|
||||||
FOREIGN KEY (system_id) REFERENCES system(id) ON DELETE CASCADE,
|
|
||||||
world_id TEXT,
|
|
||||||
FOREIGN KEY (world_id) REFERENCES world(id) ON DELETE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS journal_page (
|
CREATE TABLE IF NOT EXISTS journal_page (
|
||||||
id TEXT PRIMARY KEY,
|
id TEXT PRIMARY KEY,
|
||||||
|
|
||||||
@@ -974,19 +636,6 @@ CREATE TABLE IF NOT EXISTS journal_page_video (
|
|||||||
FOREIGN KEY (journal_page_id) REFERENCES journal_page(id) ON DELETE CASCADE
|
FOREIGN KEY (journal_page_id) REFERENCES journal_page(id) ON DELETE CASCADE
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS ownership (
|
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
|
|
||||||
player VARCHAR(128) NOT NULL,
|
|
||||||
trusted VARCHAR(128) NOT NULL,
|
|
||||||
assistant VARCHAR(128) NOT NULL,
|
|
||||||
|
|
||||||
pack_id TEXT UNIQUE,
|
|
||||||
FOREIGN KEY (pack_id) REFERENCES pack(id) ON DELETE CASCADE,
|
|
||||||
card_deck_id TEXT UNIQUE,
|
|
||||||
FOREIGN KEY (card_deck_id) REFERENCES card_deck(id) ON DELETE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS ownership_string (
|
CREATE TABLE IF NOT EXISTS ownership_string (
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
|
||||||
@@ -1006,96 +655,6 @@ CREATE TABLE IF NOT EXISTS ownership_string (
|
|||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS index_ (
|
|
||||||
id TEXT PRIMARY KEY,
|
|
||||||
|
|
||||||
folder VARCHAR(128) NOT NULL,
|
|
||||||
img VARCHAR(128) NOT NULL,
|
|
||||||
name VARCHAR(128) NOT NULL,
|
|
||||||
type VARCHAR(128) NOT NULL,
|
|
||||||
|
|
||||||
pack_id TEXT,
|
|
||||||
FOREIGN KEY (pack_id) REFERENCES pack(id) ON DELETE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS pack_folder (
|
|
||||||
id TEXT PRIMARY KEY,
|
|
||||||
|
|
||||||
description VARCHAR(128) NOT NULL,
|
|
||||||
name VARCHAR(128) NOT NULL,
|
|
||||||
sort INTEGER NOT NULL,
|
|
||||||
sorting VARCHAR(128) NOT NULL,
|
|
||||||
type VARCHAR(128) NOT NULL,
|
|
||||||
|
|
||||||
pack_id TEXT,
|
|
||||||
FOREIGN KEY (pack_id) REFERENCES pack(id) ON DELETE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS folder (
|
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
|
|
||||||
name VARCHAR(128) NOT NULL,
|
|
||||||
sorting VARCHAR(128) NOT NULL,
|
|
||||||
color VARCHAR(128) NOT NULL,
|
|
||||||
|
|
||||||
folder_id INTEGER,
|
|
||||||
FOREIGN KEY (folder_id) REFERENCES folder(id) ON DELETE CASCADE,
|
|
||||||
module_id TEXT,
|
|
||||||
FOREIGN KEY (module_id) REFERENCES module(id) ON DELETE CASCADE,
|
|
||||||
system_id TEXT,
|
|
||||||
FOREIGN KEY (system_id) REFERENCES system(id) ON DELETE CASCADE,
|
|
||||||
world_id TEXT,
|
|
||||||
FOREIGN KEY (world_id) REFERENCES world(id) ON DELETE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS folder_packs (
|
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
|
|
||||||
packs VARCHAR(128) NOT NULL,
|
|
||||||
|
|
||||||
folder_id INTEGER,
|
|
||||||
FOREIGN KEY (folder_id) REFERENCES folder(id) ON DELETE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS tags (
|
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
|
|
||||||
tags VARCHAR(128) NOT NULL,
|
|
||||||
|
|
||||||
module_id TEXT,
|
|
||||||
FOREIGN KEY (module_id) REFERENCES module(id) ON DELETE CASCADE
|
|
||||||
system_id TEXT,
|
|
||||||
FOREIGN KEY (system_id) REFERENCES system(id) ON DELETE CASCADE
|
|
||||||
world_id TEXT,
|
|
||||||
FOREIGN KEY (world_id) REFERENCES world(id) ON DELETE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS document_types (
|
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
|
|
||||||
module_id TEXT UNIQUE,
|
|
||||||
FOREIGN KEY (module_id) REFERENCES module(id) ON DELETE CASCADE
|
|
||||||
system_id TEXT UNIQUE,
|
|
||||||
FOREIGN KEY (system_id) REFERENCES system(id) ON DELETE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS document_types_data (
|
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
|
|
||||||
type VARCHAR(64) NOT NULL,
|
|
||||||
|
|
||||||
document_types_id INTEGER,
|
|
||||||
FOREIGN KEY (document_types_id) REFERENCES document_types(id) ON DELETE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS document_types_data_html (
|
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
|
|
||||||
html_fields TEXT NOT NULL,
|
|
||||||
|
|
||||||
document_types_data_id INTEGER,
|
|
||||||
FOREIGN KEY (document_types_data_id) REFERENCES document_types_data(id) ON DELETE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS system_update (
|
CREATE TABLE IF NOT EXISTS system_update (
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
@@ -1106,107 +665,3 @@ CREATE TABLE IF NOT EXISTS system_update (
|
|||||||
game_id INTEGER UNIQUE,
|
game_id INTEGER UNIQUE,
|
||||||
FOREIGN KEY (game_id) REFERENCES game(id) ON DELETE CASCADE
|
FOREIGN KEY (game_id) REFERENCES game(id) ON DELETE CASCADE
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS core_update (
|
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
|
|
||||||
has_update BOOLEAN NOT NULL DEFAULT FALSE,
|
|
||||||
can_update BOOLEAN NOT NULL DEFAULT FALSE,
|
|
||||||
could_reach_website BOOLEAN NOT NULL DEFAULT FALSE,
|
|
||||||
slow_response BOOLEAN NOT NULL DEFAULT FALSE,
|
|
||||||
version VARCHAR(64) NOT NULL,
|
|
||||||
channel VARCHAR(64) NOT NULL,
|
|
||||||
will_disable_modules BOOLEAN NOT NULL DEFAULT FALSE,
|
|
||||||
|
|
||||||
setup_id INTEGER UNIQUE,
|
|
||||||
game_id INTEGER UNIQUE,
|
|
||||||
FOREIGN KEY (setup_id) REFERENCES setup(id) ON DELETE CASCADE,
|
|
||||||
FOREIGN KEY (game_id) REFERENCES game(id) ON DELETE CASCADE,
|
|
||||||
CONSTRAINT one_parent_only CHECK (
|
|
||||||
(setup_id IS NOT NULL AND game_id IS NULL) OR
|
|
||||||
(setup_id IS NULL AND game_id IS NOT NULL)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS featured_content (
|
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
|
|
||||||
title VARCHAR(128) NOT NULL,
|
|
||||||
caption VARCHAR(128) NOT NULL,
|
|
||||||
url VARCHAR(128) NOT NULL,
|
|
||||||
image VARCHAR(128) NOT NULL,
|
|
||||||
|
|
||||||
setup_id INTEGER UNIQUE,
|
|
||||||
FOREIGN KEY (setup_id) REFERENCES setup(id) ON DELETE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS news (
|
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
|
|
||||||
title VARCHAR(64) NOT NULL,
|
|
||||||
caption VARCHAR(64) NOT NULL,
|
|
||||||
url VARCHAR(64) NOT NULL,
|
|
||||||
image VARCHAR(64) NOT NULL,
|
|
||||||
|
|
||||||
setup_id INTEGER,
|
|
||||||
FOREIGN KEY (setup_id) REFERENCES setup(id) ON DELETE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS files (
|
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
|
|
||||||
setup_id INTEGER UNIQUE,
|
|
||||||
game_id INTEGER UNIQUE,
|
|
||||||
FOREIGN KEY (setup_id) REFERENCES setup(id) ON DELETE CASCADE,
|
|
||||||
FOREIGN KEY (game_id) REFERENCES game(id) ON DELETE CASCADE,
|
|
||||||
CONSTRAINT one_parent_only CHECK (
|
|
||||||
(setup_id IS NOT NULL AND game_id IS NULL) OR
|
|
||||||
(setup_id IS NULL AND game_id IS NOT NULL)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS files_storage (
|
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
|
|
||||||
storage TEXT NOT NULL,
|
|
||||||
|
|
||||||
files_id INTEGER,
|
|
||||||
FOREIGN KEY (files_id) REFERENCES files(id) ON DELETE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS setup_language (
|
|
||||||
id INTEGER PRIMARY KEY,
|
|
||||||
|
|
||||||
label VARCHAR(128) NOT NULL,
|
|
||||||
|
|
||||||
setup_id INTEGER,
|
|
||||||
FOREIGN KEY (setup_id) REFERENCES setup(id) ON DELETE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS setup_language_module (
|
|
||||||
id TEXT PRIMARY KEY,
|
|
||||||
|
|
||||||
label VARCHAR(128) NOT NULL,
|
|
||||||
path VARCHAR(128) NOT NULL,
|
|
||||||
|
|
||||||
setup_language_id INTEGER,
|
|
||||||
FOREIGN KEY (setup_language_id) REFERENCES setup_language(id) ON DELETE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS language (
|
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
|
|
||||||
lang VARCHAR(128) NOT NULL,
|
|
||||||
name VARCHAR(128) NOT NULL,
|
|
||||||
path VARCHAR(128) NOT NULL,
|
|
||||||
|
|
||||||
module_id TEXT,
|
|
||||||
FOREIGN KEY (module_id) REFERENCES module(id) ON DELETE CASCADE,
|
|
||||||
system_id INTEGER,
|
|
||||||
FOREIGN KEY (system_id) REFERENCES system(id) ON DELETE CASCADE,
|
|
||||||
world_id INTEGER,
|
|
||||||
FOREIGN KEY (world_id) REFERENCES world(id) ON DELETE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
CREATE TABLE IF NOT EXISTS modules (
|
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
state_id INTEGER NOT NULL,
|
|
||||||
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,
|
|
||||||
FOREIGN KEY (state_id) REFERENCES foundry_state(id) ON DELETE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS modules_compatibility (
|
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
module_id INTEGER UNIQUE,
|
|
||||||
minimum VARCHAR(64) NOT NULL,
|
|
||||||
verified VARCHAR(64) NOT NULL,
|
|
||||||
maximum VARCHAR(64) NOT NULL,
|
|
||||||
|
|
||||||
FOREIGN KEY (module_id) REFERENCES modules(id) ON DELETE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS modules_languages (
|
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
module_id INTEGER,
|
|
||||||
language VARCHAR(256) NOT NULL,
|
|
||||||
name VARCHAR(256) NOT NULL,
|
|
||||||
path VARCHAR(256) NOT NULL,
|
|
||||||
|
|
||||||
FOREIGN KEY (module_id) REFERENCES modules(id) ON DELETE CASCADE
|
|
||||||
);
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
DROP TABLE IF EXISTS systems_compatibility;
|
|
||||||
DROP TABLE IF EXISTS systems;
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
CREATE TABLE IF NOT EXISTS systems (
|
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
state_id INTEGER NOT NULL,
|
|
||||||
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,
|
|
||||||
FOREIGN KEY (state_id) REFERENCES foundry_state(id) ON DELETE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
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
|
|
||||||
);
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
DROP TABLE IF EXISTS worlds_compatibility;
|
|
||||||
DROP TABLE IF EXISTS worlds;
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
CREATE TABLE IF NOT EXISTS worlds (
|
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
state_id INTEGER NOT NULL,
|
|
||||||
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,
|
|
||||||
FOREIGN KEY (state_id) REFERENCES foundry_state(id) ON DELETE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
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
|
|
||||||
);
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
DROP TABLE IF EXISTS users;
|
|
||||||
DROP TABLE IF EXISTS users_hotbar;
|
|
||||||
DROP TABLE IF EXISTS users_stats;
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
CREATE TABLE IF NOT EXISTS users (
|
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
state_id INTEGER NOT NULL,
|
|
||||||
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,
|
|
||||||
FOREIGN KEY (state_id) REFERENCES foundry_state(id) ON DELETE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
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 UNIQUE,
|
|
||||||
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
|
|
||||||
);
|
|
||||||
@@ -1,5 +1,12 @@
|
|||||||
package db
|
package db
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/jmoiron/sqlx"
|
||||||
|
)
|
||||||
|
|
||||||
type Author struct {
|
type Author struct {
|
||||||
ID uint
|
ID uint
|
||||||
|
|
||||||
@@ -9,3 +16,40 @@ type Author struct {
|
|||||||
Discord string
|
Discord string
|
||||||
// SystemAuthorsFlags SystemAuthorsFlags `json:"flags"`
|
// SystemAuthorsFlags SystemAuthorsFlags `json:"flags"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *Author) Query(data *InsertId[string]) {
|
||||||
|
data.query = fmt.Sprintf(`
|
||||||
|
INSERT INTO author (%s, name, url, email, discord)
|
||||||
|
VALUES ($1, $2, $3, $4, $5)
|
||||||
|
RETURNING id`, data.fieldName)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *Author) Insert(tx *sqlx.Tx, data *InsertId[string]) error {
|
||||||
|
if data.query == "" {
|
||||||
|
return ErrNoQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
args := []any{data.id, a.Name, a.URL, a.Email, a.Discord}
|
||||||
|
|
||||||
|
err := tx.QueryRow(data.query, args...).Scan(&a.ID)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *Author) InsertCtx(ctx context.Context, tx *sqlx.Tx, data *InsertId[string]) error {
|
||||||
|
if data.query == "" {
|
||||||
|
return ErrNoQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
args := []any{data.id, a.Name, a.URL, a.Email, a.Discord}
|
||||||
|
|
||||||
|
err := tx.QueryRowContext(ctx, data.query, args...).Scan(&a.ID)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
package db
|
package db
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/jmoiron/sqlx"
|
||||||
|
)
|
||||||
|
|
||||||
type Compatibility struct {
|
type Compatibility struct {
|
||||||
ID uint
|
ID uint
|
||||||
|
|
||||||
@@ -7,3 +14,40 @@ type Compatibility struct {
|
|||||||
Verified string
|
Verified string
|
||||||
Maximum string
|
Maximum string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c Compatibility) Query(data *InsertId[string]) {
|
||||||
|
data.query = fmt.Sprintf(`
|
||||||
|
INSERT INTO compatibility (%s, minimum, verified, maximum)
|
||||||
|
VALUES ($1, $2, $3, $4)
|
||||||
|
RETURNING id`, data.fieldName)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c Compatibility) Insert(tx *sqlx.Tx, data *InsertId[string]) error {
|
||||||
|
if data.query == "" {
|
||||||
|
return ErrNoQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
args := []any{data.id, c.Minimum, c.Verified, c.Maximum}
|
||||||
|
|
||||||
|
err := tx.QueryRow(data.query, args...).Scan(&c.ID)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c Compatibility) InsertCtx(ctx context.Context, tx *sqlx.Tx, data *InsertId[string]) error {
|
||||||
|
if data.query == "" {
|
||||||
|
return ErrNoQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
args := []any{data.id, c.Minimum, c.Verified, c.Maximum}
|
||||||
|
|
||||||
|
err := tx.QueryRowContext(ctx, data.query, args...).Scan(&c.ID)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,9 +1,60 @@
|
|||||||
package db
|
package db
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/jmoiron/sqlx"
|
||||||
|
)
|
||||||
|
|
||||||
type DocumentTypes struct {
|
type DocumentTypes struct {
|
||||||
ID uint
|
ID uint
|
||||||
|
|
||||||
Data []DocumentTypeData
|
Data []*DocumentTypeData
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d DocumentTypes) Query(data *InsertId[string]) {
|
||||||
|
data.query = `
|
||||||
|
INSERT INTO document_types (module_id)
|
||||||
|
VALUES ($1)
|
||||||
|
RETURNING id`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d DocumentTypes) Insert(tx *sqlx.Tx, data *InsertId[string]) error {
|
||||||
|
if data.query == "" {
|
||||||
|
return ErrNoQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
args := []any{data.id}
|
||||||
|
|
||||||
|
err := tx.QueryRow(data.query, args...).Scan(&d.ID)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
syncDB := NewSyncDB()
|
||||||
|
defer close(syncDB.errChan)
|
||||||
|
InsertSliceParallel(syncDB, tx, d.Data, &InsertId[uint]{id: d.ID})
|
||||||
|
|
||||||
|
return syncDB.Wait()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d DocumentTypes) InsertCtx(ctx context.Context, tx *sqlx.Tx, data *InsertId[string]) error {
|
||||||
|
if data.query == "" {
|
||||||
|
return ErrNoQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
args := []any{data.id}
|
||||||
|
|
||||||
|
err := tx.QueryRowContext(ctx, data.query, args...).Scan(&d.ID)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
syncDB := NewSyncDB()
|
||||||
|
defer close(syncDB.errChan)
|
||||||
|
InsertSliceParallel(syncDB, tx, d.Data, &InsertId[uint]{id: d.ID})
|
||||||
|
|
||||||
|
return syncDB.Wait()
|
||||||
}
|
}
|
||||||
|
|
||||||
type DocumentTypeData struct {
|
type DocumentTypeData struct {
|
||||||
@@ -12,3 +63,50 @@ type DocumentTypeData struct {
|
|||||||
Type string
|
Type string
|
||||||
HtmlFields []string
|
HtmlFields []string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *DocumentTypeData) Query(data *InsertId[uint]) {
|
||||||
|
data.query = `
|
||||||
|
INSERT INTO document_types_data (document_types_id, type)
|
||||||
|
VALUES ($1, $2)
|
||||||
|
RETURNING id`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *DocumentTypeData) Insert(tx *sqlx.Tx, data *InsertId[uint]) error {
|
||||||
|
if data.query == "" {
|
||||||
|
return ErrNoQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
args := []any{data.id, d.Type}
|
||||||
|
|
||||||
|
err := tx.QueryRow(data.query, args...).Scan(&d.ID)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
syncDB := NewSyncDB()
|
||||||
|
defer close(syncDB.errChan)
|
||||||
|
relData := &InsertId[uint]{id: d.ID, fieldName: "document_types_data_id", tableName: "document_types_data_html"}
|
||||||
|
InsertSimpleSliceParallel(syncDB, tx, d.HtmlFields, relData)
|
||||||
|
|
||||||
|
return syncDB.Wait()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *DocumentTypeData) InsertCtx(ctx context.Context, tx *sqlx.Tx, data *InsertId[uint]) error {
|
||||||
|
if data.query == "" {
|
||||||
|
return ErrNoQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
args := []any{data.id, d.Type}
|
||||||
|
|
||||||
|
err := tx.QueryRowContext(ctx, data.query, args...).Scan(&d.ID)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
syncDB := NewSyncDB()
|
||||||
|
defer close(syncDB.errChan)
|
||||||
|
relData := &InsertId[uint]{id: d.ID, fieldName: "document_types_data_id", tableName: "document_types_data_html"}
|
||||||
|
InsertSimpleSliceParallel(syncDB, tx, d.HtmlFields, relData)
|
||||||
|
|
||||||
|
return syncDB.Wait()
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package db
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"sync"
|
|
||||||
|
|
||||||
"github.com/jmoiron/sqlx"
|
"github.com/jmoiron/sqlx"
|
||||||
)
|
)
|
||||||
@@ -14,48 +13,49 @@ type Files struct {
|
|||||||
Storages []FilesStorage
|
Storages []FilesStorage
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Files) Insert(tx *sqlx.Tx, data *InsertId[uint]) error {
|
func (f *Files) Query(data *InsertId[uint]) {
|
||||||
query := fmt.Sprintf(`
|
data.query = fmt.Sprintf(`
|
||||||
INSERT INTO files (%s)
|
INSERT INTO files (%s)
|
||||||
VALUES ($1)
|
VALUES ($1)
|
||||||
RETURNING id`, data.fieldName)
|
RETURNING id`, data.fieldName)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *Files) Insert(tx *sqlx.Tx, data *InsertId[uint]) error {
|
||||||
|
if data.query == "" {
|
||||||
|
return ErrNoQuery
|
||||||
|
}
|
||||||
|
|
||||||
args := []any{data.id}
|
args := []any{data.id}
|
||||||
|
|
||||||
err := tx.QueryRowx(query, args...).Scan(&f.ID)
|
err := tx.QueryRowx(data.query, args...).Scan(&f.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
syncDB := SyncDbOperations{
|
syncDB := NewSyncDB()
|
||||||
wg: sync.WaitGroup{},
|
defer close(syncDB.errChan)
|
||||||
errChan: make(chan error),
|
|
||||||
}
|
|
||||||
|
|
||||||
InsertSliceParallel[uint](&syncDB, tx, f.Storages, &InsertId[uint]{id: f.ID})
|
InsertSliceParallel(syncDB, tx, f.Storages, &InsertId[uint]{id: f.ID})
|
||||||
|
|
||||||
return syncDB.Wait()
|
return syncDB.Wait()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Files) InsertCtx(ctx context.Context, tx *sqlx.Tx, data *InsertId[uint]) error {
|
func (f *Files) InsertCtx(ctx context.Context, tx *sqlx.Tx, data *InsertId[uint]) error {
|
||||||
query := fmt.Sprintf(`
|
if data.query == "" {
|
||||||
INSERT INTO files (%s)
|
return ErrNoQuery
|
||||||
VALUES ($1)
|
}
|
||||||
RETURNING id`, data.fieldName)
|
|
||||||
|
|
||||||
args := []any{data.id}
|
args := []any{data.id}
|
||||||
|
|
||||||
err := tx.QueryRowxContext(ctx, query, args...).Scan(&f.ID)
|
err := tx.QueryRowxContext(ctx, data.query, args...).Scan(&f.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
syncDB := SyncDbOperations{
|
syncDB := NewSyncDB()
|
||||||
wg: sync.WaitGroup{},
|
defer close(syncDB.errChan)
|
||||||
errChan: make(chan error),
|
|
||||||
}
|
|
||||||
|
|
||||||
InsertSliceParallel(&syncDB, tx, f.Storages, &InsertId[uint]{id: f.ID})
|
InsertSliceParallel(syncDB, tx, f.Storages, &InsertId[uint]{id: f.ID})
|
||||||
|
|
||||||
return syncDB.Wait()
|
return syncDB.Wait()
|
||||||
}
|
}
|
||||||
@@ -66,15 +66,21 @@ type FilesStorage struct {
|
|||||||
Storage string
|
Storage string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f FilesStorage) Insert(tx *sqlx.Tx, data *InsertId[uint]) error {
|
func (f FilesStorage) Query(data *InsertId[uint]) {
|
||||||
query := `
|
data.query = `
|
||||||
INSERT INTO files (files_id, storage)
|
INSERT INTO files_storage (files_id, storage)
|
||||||
VALUES ($1, $2)
|
VALUES ($1, $2)
|
||||||
RETURNING id`
|
RETURNING id`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f FilesStorage) Insert(tx *sqlx.Tx, data *InsertId[uint]) error {
|
||||||
|
if data.query == "" {
|
||||||
|
return ErrNoQuery
|
||||||
|
}
|
||||||
|
|
||||||
args := []any{data.id, f.Storage}
|
args := []any{data.id, f.Storage}
|
||||||
|
|
||||||
err := tx.QueryRowx(query, args...).Scan(&f.ID)
|
err := tx.QueryRowx(data.query, args...).Scan(&f.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -83,14 +89,13 @@ func (f FilesStorage) Insert(tx *sqlx.Tx, data *InsertId[uint]) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (f FilesStorage) InsertCtx(ctx context.Context, tx *sqlx.Tx, data *InsertId[uint]) error {
|
func (f FilesStorage) InsertCtx(ctx context.Context, tx *sqlx.Tx, data *InsertId[uint]) error {
|
||||||
const query = `
|
if data.query == "" {
|
||||||
INSERT INTO featured_content (files_id, storage)
|
return ErrNoQuery
|
||||||
VALUES ($1, $2)
|
}
|
||||||
RETURNING id`
|
|
||||||
|
|
||||||
args := []any{data.id, f.Storage}
|
args := []any{data.id, f.Storage}
|
||||||
|
|
||||||
err := tx.QueryRowxContext(ctx, query, args...).Scan(&f.ID)
|
err := tx.QueryRowxContext(ctx, data.query, args...).Scan(&f.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,13 @@
|
|||||||
package db
|
package db
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/jmoiron/sqlx"
|
||||||
|
)
|
||||||
|
|
||||||
type Folder struct {
|
type Folder struct {
|
||||||
ID uint
|
ID uint
|
||||||
|
|
||||||
@@ -7,7 +15,59 @@ type Folder struct {
|
|||||||
Sorting string
|
Sorting string
|
||||||
Color string
|
Color string
|
||||||
Packs []string
|
Packs []string
|
||||||
Folders []Folder
|
Folders []*Folder
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *Folder) Query(data *InsertId[string]) {
|
||||||
|
data.query = fmt.Sprintf(`
|
||||||
|
INSERT INTO folder (%s, name, sorting, color)
|
||||||
|
VALUES ($1, $2, $3, $4)
|
||||||
|
RETURNING id`, data.fieldName)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *Folder) InsertObjects(tx *sqlx.Tx) error {
|
||||||
|
relId := &InsertId[string]{
|
||||||
|
id: strconv.FormatUint(uint64(f.ID), 10),
|
||||||
|
fieldName: "folder_id",
|
||||||
|
tableName: "folder_packs",
|
||||||
|
}
|
||||||
|
syncDB := NewSyncDB()
|
||||||
|
defer close(syncDB.errChan)
|
||||||
|
|
||||||
|
InsertSimpleSliceParallel(syncDB, tx, f.Packs, relId)
|
||||||
|
InsertSliceParallel(syncDB, tx, f.Folders, relId)
|
||||||
|
|
||||||
|
return syncDB.Wait()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *Folder) Insert(tx *sqlx.Tx, data *InsertId[string]) error {
|
||||||
|
if data.query == "" {
|
||||||
|
return ErrNoQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
args := []any{data.id, f.Name, f.Sorting, f.Color}
|
||||||
|
|
||||||
|
err := tx.QueryRow(data.query, args...).Scan(&f.ID)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return f.InsertObjects(tx)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *Folder) InsertCtx(ctx context.Context, tx *sqlx.Tx, data *InsertId[string]) error {
|
||||||
|
if data.query == "" {
|
||||||
|
return ErrNoQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
args := []any{data.id, f.Name, f.Sorting, f.Color}
|
||||||
|
|
||||||
|
err := tx.QueryRowContext(ctx, data.query, args...).Scan(&f.ID)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return f.InsertObjects(tx)
|
||||||
}
|
}
|
||||||
|
|
||||||
type WorldFolder struct {
|
type WorldFolder struct {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ type Game struct {
|
|||||||
ActiveUsers []string
|
ActiveUsers []string
|
||||||
Modules []*Module
|
Modules []*Module
|
||||||
PackageWarnings []*PackageWarning
|
PackageWarnings []*PackageWarning
|
||||||
Packs []Pack
|
Packs []*Pack
|
||||||
Messages []Message
|
Messages []Message
|
||||||
Combats []Combat
|
Combats []Combat
|
||||||
CardDeck []CardDeck
|
CardDeck []CardDeck
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
package db
|
package db
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/jmoiron/sqlx"
|
||||||
|
)
|
||||||
|
|
||||||
type Grid struct {
|
type Grid struct {
|
||||||
ID uint
|
ID uint
|
||||||
|
|
||||||
@@ -13,3 +19,43 @@ type Grid struct {
|
|||||||
Units string
|
Units string
|
||||||
Style string
|
Style string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *Grid) Query(data *InsertId[string]) {
|
||||||
|
data.query = `
|
||||||
|
INSERT INTO grid (system_id, type, size, distance, diagonals, thickness
|
||||||
|
alpha, color, units, style)
|
||||||
|
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)
|
||||||
|
RETURNING id`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Grid) Insert(tx *sqlx.Tx, data *InsertId[string]) error {
|
||||||
|
if data.query == "" {
|
||||||
|
return ErrNoQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
args := []any{data.id, g.Type, g.Size, g.Distance, g.Diagonals, g.Thickness,
|
||||||
|
g.Alpha, g.Color, g.Units, g.Style}
|
||||||
|
|
||||||
|
err := tx.QueryRowx(data.query, args...).Scan(&g.ID)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Grid) InsertCtx(ctx context.Context, tx *sqlx.Tx, data *InsertId[string]) error {
|
||||||
|
if data.query == "" {
|
||||||
|
return ErrNoQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
args := []any{data.id, g.Type, g.Size, g.Distance, g.Diagonals, g.Thickness,
|
||||||
|
g.Alpha, g.Color, g.Units, g.Style}
|
||||||
|
|
||||||
|
err := tx.QueryRowxContext(ctx, data.query, args...).Scan(&g.ID)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
package db
|
package db
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/jmoiron/sqlx"
|
||||||
|
)
|
||||||
|
|
||||||
type Index struct {
|
type Index struct {
|
||||||
ID string
|
ID string
|
||||||
|
|
||||||
@@ -8,3 +14,40 @@ type Index struct {
|
|||||||
Name string
|
Name string
|
||||||
Type string
|
Type string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (i *Index) Query(data *InsertId[string]) {
|
||||||
|
data.query = `
|
||||||
|
INSERT INTO index_ (pack_id, id, folder, img, name, type)
|
||||||
|
VALUES ($1, $2, $3, $4, $5, $6)
|
||||||
|
RETURNING id`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i *Index) Insert(tx *sqlx.Tx, data *InsertId[string]) error {
|
||||||
|
if data.query == "" {
|
||||||
|
return ErrNoQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
args := []any{data.id, i.ID, i.Folder, i.Img, i.Name, i.Type}
|
||||||
|
|
||||||
|
_, err := tx.Exec(data.query, args...)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i *Index) InsertCtx(ctx context.Context, tx *sqlx.Tx, data *InsertId[string]) error {
|
||||||
|
if data.query == "" {
|
||||||
|
return ErrNoQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
args := []any{data.id, i.ID, i.Folder, i.Img, i.Name, i.Type}
|
||||||
|
|
||||||
|
_, err := tx.ExecContext(ctx, data.query, args...)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,18 +2,11 @@ package db
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/jmoiron/sqlx"
|
"github.com/jmoiron/sqlx"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Language struct {
|
|
||||||
ID uint
|
|
||||||
|
|
||||||
Lang string
|
|
||||||
Name string
|
|
||||||
Path string
|
|
||||||
}
|
|
||||||
|
|
||||||
type SetupLanguage struct {
|
type SetupLanguage struct {
|
||||||
ID string
|
ID string
|
||||||
|
|
||||||
@@ -21,38 +14,47 @@ type SetupLanguage struct {
|
|||||||
Modules []SetupLanguageModule
|
Modules []SetupLanguageModule
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l SetupLanguage) Insert(tx *sqlx.Tx, data *InsertId[uint]) error {
|
func (l *SetupLanguage) Query(data *InsertId[uint]) {
|
||||||
const query = `
|
data.query = `
|
||||||
INSERT INTO setup_language (setup_id, label)
|
INSERT INTO setup_language (setup_id, label)
|
||||||
VALUES ($1, $2)
|
VALUES ($1, $2)
|
||||||
RETURNING id`
|
RETURNING id`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *SetupLanguage) Insert(tx *sqlx.Tx, data *InsertId[uint]) error {
|
||||||
|
if data.query == "" {
|
||||||
|
return ErrNoQuery
|
||||||
|
}
|
||||||
|
|
||||||
args := []any{data.id, l.Label}
|
args := []any{data.id, l.Label}
|
||||||
|
|
||||||
err := tx.QueryRowx(query, args...).Scan(&l.ID)
|
err := tx.QueryRowx(data.query, args...).Scan(&l.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
InsertSlice(tx, l.Modules, &InsertId[string]{id: l.ID})
|
syncDB := NewSyncDB()
|
||||||
|
defer close(syncDB.errChan)
|
||||||
|
InsertSliceParallel(syncDB, tx, l.Modules, &InsertId[string]{id: l.ID})
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l SetupLanguage) InsertCtx(ctx context.Context, tx *sqlx.Tx, data *InsertId[uint]) error {
|
func (l *SetupLanguage) InsertCtx(ctx context.Context, tx *sqlx.Tx, data *InsertId[uint]) error {
|
||||||
const query = `
|
if data.query == "" {
|
||||||
INSERT INTO setup_language (setup_id, label)
|
return ErrNoQuery
|
||||||
VALUES ($1, $2)
|
}
|
||||||
RETURNING id`
|
|
||||||
|
|
||||||
args := []any{data.id, l.Label}
|
args := []any{data.id, l.Label}
|
||||||
|
|
||||||
err := tx.QueryRowxContext(ctx, query, args...).Scan(&l.ID)
|
err := tx.QueryRowxContext(ctx, data.query, args...).Scan(&l.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
InsertSlice(tx, l.Modules, &InsertId[string]{id: l.ID})
|
syncDB := NewSyncDB()
|
||||||
|
defer close(syncDB.errChan)
|
||||||
|
InsertSliceParallel(syncDB, tx, l.Modules, &InsertId[string]{id: l.ID})
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -64,15 +66,21 @@ type SetupLanguageModule struct {
|
|||||||
Path string
|
Path string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l SetupLanguageModule) Insert(tx *sqlx.Tx, data *InsertId[string]) error {
|
func (l SetupLanguageModule) Query(data *InsertId[string]) {
|
||||||
const query = `
|
data.query = `
|
||||||
INSERT INTO setup_language_module (setup_language_id, label, path)
|
INSERT INTO setup_language_module (setup_language_id, id, label, path)
|
||||||
VALUES ($1, $2, $3)
|
VALUES ($1, $2, $3, $4)
|
||||||
RETURNING id`
|
RETURNING id`
|
||||||
|
}
|
||||||
|
|
||||||
args := []any{data.id, l.Label, l.Path}
|
func (l SetupLanguageModule) Insert(tx *sqlx.Tx, data *InsertId[string]) error {
|
||||||
|
if data.query == "" {
|
||||||
|
return ErrNoQuery
|
||||||
|
}
|
||||||
|
|
||||||
err := tx.QueryRowx(query, args...).Scan(&l.ID)
|
args := []any{data.id, l.ID, l.Label, l.Path}
|
||||||
|
|
||||||
|
_, err := tx.Exec(data.query, args...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -81,14 +89,58 @@ func (l SetupLanguageModule) Insert(tx *sqlx.Tx, data *InsertId[string]) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (l SetupLanguageModule) InsertCtx(ctx context.Context, tx *sqlx.Tx, data *InsertId[string]) error {
|
func (l SetupLanguageModule) InsertCtx(ctx context.Context, tx *sqlx.Tx, data *InsertId[string]) error {
|
||||||
const query = `
|
if data.query == "" {
|
||||||
INSERT INTO setup_language_module (setup_language_id, label, path)
|
return ErrNoQuery
|
||||||
VALUES ($1, $2, $3)
|
}
|
||||||
RETURNING id`
|
|
||||||
|
|
||||||
args := []any{data.id, l.Label, l.Path}
|
args := []any{data.id, l.ID, l.Label, l.Path}
|
||||||
|
|
||||||
err := tx.QueryRowxContext(ctx, query, args...).Scan(&l.ID)
|
_, err := tx.ExecContext(ctx, data.query, args...)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type Language struct {
|
||||||
|
ID uint
|
||||||
|
|
||||||
|
Lang string
|
||||||
|
Name string
|
||||||
|
Path string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *Language) Query(data *InsertId[string]) {
|
||||||
|
data.query = fmt.Sprintf(`
|
||||||
|
INSERT INTO language (%s, lang, name, path)
|
||||||
|
VALUES ($1, $2, $3, $4)
|
||||||
|
RETURNING id`, data.fieldName)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *Language) Insert(tx *sqlx.Tx, data *InsertId[string]) error {
|
||||||
|
if data.query == "" {
|
||||||
|
return ErrNoQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
args := []any{data.id, l.Lang, l.Name, l.Path}
|
||||||
|
|
||||||
|
err := tx.QueryRow(data.query, args...).Scan(&l.ID)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *Language) InsertCtx(ctx context.Context, tx *sqlx.Tx, data *InsertId[string]) error {
|
||||||
|
if data.query == "" {
|
||||||
|
return ErrNoQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
args := []any{data.id, l.Lang, l.Name, l.Path}
|
||||||
|
|
||||||
|
err := tx.QueryRowContext(ctx, data.query, args...).Scan(&l.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
package db
|
package db
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/jmoiron/sqlx"
|
||||||
|
)
|
||||||
|
|
||||||
type Media struct {
|
type Media struct {
|
||||||
ID uint
|
ID uint
|
||||||
|
|
||||||
@@ -7,3 +14,40 @@ type Media struct {
|
|||||||
URL string
|
URL string
|
||||||
Caption string
|
Caption string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *Media) Query(data *InsertId[string]) {
|
||||||
|
data.query = fmt.Sprintf(`
|
||||||
|
INSERT INTO media (%s, type, url, caption)
|
||||||
|
VALUES ($1, $2, $3, $4)
|
||||||
|
RETURNING id`, data.fieldName)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Media) Insert(tx *sqlx.Tx, data *InsertId[string]) error {
|
||||||
|
if data.query == "" {
|
||||||
|
return ErrNoQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
args := []any{data.id, m.Type, m.URL, m.Caption}
|
||||||
|
|
||||||
|
err := tx.QueryRow(data.query, args...).Scan(&m.ID)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Media) InsertCtx(ctx context.Context, tx *sqlx.Tx, data *InsertId[string]) error {
|
||||||
|
if data.query == "" {
|
||||||
|
return ErrNoQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
args := []any{data.id, m.Type, m.URL, m.Caption}
|
||||||
|
|
||||||
|
err := tx.QueryRowContext(ctx, data.query, args...).Scan(&m.ID)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
package db
|
package db
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/jmoiron/sqlx"
|
||||||
|
)
|
||||||
|
|
||||||
type Module struct {
|
type Module struct {
|
||||||
ID string
|
ID string
|
||||||
|
|
||||||
@@ -11,30 +18,98 @@ type Module struct {
|
|||||||
Bugs string
|
Bugs string
|
||||||
Changelog string
|
Changelog string
|
||||||
Version string
|
Version string
|
||||||
Socket bool
|
|
||||||
Manifest string
|
|
||||||
Download string
|
Download string
|
||||||
|
Manifest string
|
||||||
|
Socket bool
|
||||||
Protected bool
|
Protected bool
|
||||||
Exclusive bool
|
Exclusive bool
|
||||||
PersistentStorage bool
|
PersistentStorage bool
|
||||||
CoreTranslation bool
|
CoreTranslation bool
|
||||||
Library bool
|
Library bool
|
||||||
Availability int
|
|
||||||
Locked bool
|
Locked bool
|
||||||
Owned bool
|
Owned bool
|
||||||
HasStorage bool
|
HasStorage bool
|
||||||
Active bool
|
Active bool
|
||||||
|
Availability int
|
||||||
DocumentTypes DocumentTypes
|
DocumentTypes DocumentTypes
|
||||||
Relationships Relationships
|
Relationships Relationships
|
||||||
Compatibility Compatibility
|
Compatibility Compatibility
|
||||||
Authors []Author
|
|
||||||
Media []Media
|
|
||||||
Scripts []string
|
Scripts []string
|
||||||
Esmodules []string
|
Esmodules []string
|
||||||
Styles []Style
|
|
||||||
Languages []Language
|
|
||||||
Packs []Pack
|
|
||||||
PackFolders []Folder
|
|
||||||
Tags []string
|
Tags []string
|
||||||
// ModulesFlags ModulesFlags `json:"flags,omitempty"`
|
Authors []*Author
|
||||||
|
Media []*Media
|
||||||
|
Styles []*Style
|
||||||
|
Languages []*Language
|
||||||
|
Packs []*Pack
|
||||||
|
PackFolders []*Folder
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Module) Query(data *InsertId[uint]) {
|
||||||
|
data.query = fmt.Sprintf(`
|
||||||
|
INSERT INTO module (%s, id, title, description, url, license, readme, bugs,
|
||||||
|
changelog, version, manifest, download, socket, protected, exclusive_, persistent_storage,
|
||||||
|
core_translation, library, locked, owned, has_storage, active, availability)
|
||||||
|
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17,
|
||||||
|
$18, $19, $20, $21, $22, $23)`, data.fieldName)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Module) InsertObjects(tx *sqlx.Tx) error {
|
||||||
|
relId := &InsertId[string]{id: m.ID, fieldName: "module_id"}
|
||||||
|
syncDB := NewSyncDB()
|
||||||
|
defer close(syncDB.errChan)
|
||||||
|
|
||||||
|
go InsertWithCtxParallel(syncDB, tx, m.DocumentTypes, relId)
|
||||||
|
go InsertWithCtxParallel(syncDB, tx, m.Relationships, relId)
|
||||||
|
go InsertWithCtxParallel(syncDB, tx, m.Compatibility, relId)
|
||||||
|
|
||||||
|
scriptRelId := &InsertId[string]{id: m.ID, fieldName: "module_id", tableName: "scripts"}
|
||||||
|
go InsertSimpleSliceParallel(syncDB, tx, m.Scripts, scriptRelId)
|
||||||
|
esModulesRelId := &InsertId[string]{id: m.ID, fieldName: "module_id", tableName: "es_modules"}
|
||||||
|
go InsertSimpleSliceParallel(syncDB, tx, m.Esmodules, esModulesRelId)
|
||||||
|
tagsRelId := &InsertId[string]{id: m.ID, fieldName: "module_id", tableName: "tags"}
|
||||||
|
go InsertSimpleSliceParallel(syncDB, tx, m.Tags, tagsRelId)
|
||||||
|
|
||||||
|
go InsertSliceParallel(syncDB, tx, m.Authors, relId)
|
||||||
|
go InsertSliceParallel(syncDB, tx, m.Media, relId)
|
||||||
|
go InsertSliceParallel(syncDB, tx, m.Styles, relId)
|
||||||
|
go InsertSliceParallel(syncDB, tx, m.Languages, relId)
|
||||||
|
go InsertSliceParallel(syncDB, tx, m.Packs, relId)
|
||||||
|
go InsertSliceParallel(syncDB, tx, m.PackFolders, relId)
|
||||||
|
|
||||||
|
return syncDB.Wait()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Module) Insert(tx *sqlx.Tx, data *InsertId[uint]) error {
|
||||||
|
if data.query == "" {
|
||||||
|
return ErrNoQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
args := []any{data.id, m.ID, m.Title, m.Description, m.URL, m.License, m.Readme, m.Bugs,
|
||||||
|
m.Changelog, m.Version, m.Manifest, m.Download, m.Socket, m.Protected, m.Exclusive, m.PersistentStorage,
|
||||||
|
m.CoreTranslation, m.Library, m.Locked, m.Owned, m.HasStorage, m.Active, m.Availability}
|
||||||
|
|
||||||
|
_, err := tx.Exec(data.query, args...)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return m.InsertObjects(tx)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Module) InsertCtx(ctx context.Context, tx *sqlx.Tx, data *InsertId[uint]) error {
|
||||||
|
if data.query == "" {
|
||||||
|
return ErrNoQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
args := []any{data.id, m.ID, m.Title, m.Description, m.URL, m.License, m.Readme, m.Bugs,
|
||||||
|
m.Changelog, m.Version, m.Manifest, m.Download, m.Socket, m.Protected, m.Exclusive, m.PersistentStorage,
|
||||||
|
m.CoreTranslation, m.Library, m.Locked, m.Owned, m.HasStorage, m.Active, m.Availability}
|
||||||
|
|
||||||
|
_, err := tx.ExecContext(ctx, data.query, args...)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return m.InsertObjects(tx)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,19 +67,25 @@ type SetupOptions struct {
|
|||||||
NoBackups bool
|
NoBackups bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SetupOptions) Insert(tx *sqlx.Tx, setupId *InsertId[uint]) error {
|
func (s *SetupOptions) Query(data *InsertId[uint]) {
|
||||||
query := `
|
data.query = `
|
||||||
INSERT INTO featured_content (setup_id, compress_socket, compress_static, css_theme, data_path,
|
INSERT INTO setup_options (setup_id, css_theme, data_path, hostname, language, local_hostname,
|
||||||
fullscreen, hostname, hot_reload, language, local_hostname, port,
|
update_channel, port, compress_socket, compress_static, fullscreen, hot_reload, proxy_ssl,
|
||||||
proxy_ssl, telemetry, update_channel, upnp, delete_nedb, no_backups)
|
telemetry, upnp, delete_nedb, no_backups,)
|
||||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17)
|
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17)
|
||||||
RETURNING id`
|
RETURNING id`
|
||||||
|
}
|
||||||
|
|
||||||
args := []any{setupId.id, s.CompressSocket, s.CompressStatic, s.CSSTheme, s.DataPath,
|
func (s *SetupOptions) Insert(tx *sqlx.Tx, data *InsertId[uint]) error {
|
||||||
s.Fullscreen, s.Hostname, s.HotReload, s.Language, s.LocalHostname, s.Port,
|
if data.query == "" {
|
||||||
s.ProxySSL, s.Telemetry, s.UpdateChannel, s.Upnp, s.DeleteNEDB, s.NoBackups}
|
return ErrNoQuery
|
||||||
|
}
|
||||||
|
|
||||||
err := tx.QueryRowx(query, args...).Scan(&s.ID)
|
args := []any{data.id, s.CSSTheme, s.DataPath, s.Hostname, s.Language, s.LocalHostname,
|
||||||
|
s.UpdateChannel, s.Port, s.CompressSocket, s.CompressStatic, s.Fullscreen, s.HotReload,
|
||||||
|
s.ProxySSL, s.Telemetry, s.Upnp, s.DeleteNEDB, s.NoBackups}
|
||||||
|
|
||||||
|
err := tx.QueryRowx(data.query, args...).Scan(&s.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -87,19 +93,16 @@ func (s *SetupOptions) Insert(tx *sqlx.Tx, setupId *InsertId[uint]) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SetupOptions) InsertCtx(ctx context.Context, tx *sqlx.Tx, setupId *InsertId[uint]) error {
|
func (s *SetupOptions) InsertCtx(ctx context.Context, tx *sqlx.Tx, data *InsertId[uint]) error {
|
||||||
query := `
|
if data.query == "" {
|
||||||
INSERT INTO featured_content (setup_id, compress_socket, compress_static, css_theme, data_path,
|
return ErrNoQuery
|
||||||
fullscreen, hostname, hot_reload, language, local_hostname, port,
|
}
|
||||||
proxy_ssl, telemetry, update_channel, upnp, delete_nedb, no_backups)
|
|
||||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17)
|
|
||||||
RETURNING id`
|
|
||||||
|
|
||||||
args := []any{setupId.id, s.CompressSocket, s.CompressStatic, s.CSSTheme, s.DataPath,
|
args := []any{data.id, s.CSSTheme, s.DataPath, s.Hostname, s.Language, s.LocalHostname,
|
||||||
s.Fullscreen, s.Hostname, s.HotReload, s.Language, s.LocalHostname, s.Port,
|
s.UpdateChannel, s.Port, s.CompressSocket, s.CompressStatic, s.Fullscreen, s.HotReload,
|
||||||
s.ProxySSL, s.Telemetry, s.UpdateChannel, s.Upnp, s.DeleteNEDB, s.NoBackups}
|
s.ProxySSL, s.Telemetry, s.Upnp, s.DeleteNEDB, s.NoBackups}
|
||||||
|
|
||||||
err := tx.QueryRowxContext(ctx, query, args...).Scan(&s.ID)
|
err := tx.QueryRowxContext(ctx, data.query, args...).Scan(&s.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
package db
|
package db
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/jmoiron/sqlx"
|
||||||
|
)
|
||||||
|
|
||||||
type Ownership struct {
|
type Ownership struct {
|
||||||
ID uint
|
ID uint
|
||||||
|
|
||||||
@@ -8,6 +14,43 @@ type Ownership struct {
|
|||||||
Assistant string
|
Assistant string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (o Ownership) Query(data *InsertId[string]) {
|
||||||
|
data.query = `
|
||||||
|
INSERT INTO ownership (%s, player, trusted, assistant)
|
||||||
|
VALUES ($1, $2, $3, $4)
|
||||||
|
RETURNING id`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o Ownership) Insert(tx *sqlx.Tx, data *InsertId[string]) error {
|
||||||
|
if data.query == "" {
|
||||||
|
return ErrNoQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
args := []any{data.id, o.Player, o.Trusted, o.Assistant}
|
||||||
|
|
||||||
|
err := tx.QueryRow(data.query, args...).Scan(&o.ID)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o Ownership) InsertCtx(ctx context.Context, tx *sqlx.Tx, data *InsertId[string]) error {
|
||||||
|
if data.query == "" {
|
||||||
|
return ErrNoQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
args := []any{data.id, o.Player, o.Trusted, o.Assistant}
|
||||||
|
|
||||||
|
err := tx.QueryRowContext(ctx, data.query, args...).Scan(&o.ID)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
type OwnershipString struct {
|
type OwnershipString struct {
|
||||||
ID uint
|
ID uint
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
package db
|
package db
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/jmoiron/sqlx"
|
||||||
|
)
|
||||||
|
|
||||||
type Pack struct {
|
type Pack struct {
|
||||||
ID string
|
ID string
|
||||||
|
|
||||||
@@ -12,8 +19,57 @@ type Pack struct {
|
|||||||
PackageType string
|
PackageType string
|
||||||
PackageName string
|
PackageName string
|
||||||
Ownership Ownership
|
Ownership Ownership
|
||||||
Index []Index
|
Index []*Index
|
||||||
Folders []PackFolder
|
Folders []*PackFolder
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Pack) Query(data *InsertId[string]) {
|
||||||
|
data.query = fmt.Sprintf(`
|
||||||
|
INSERT INTO pack (%s, id, name, label, banner, path, type, system, package_type, package_name)
|
||||||
|
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)
|
||||||
|
RETURNING id`, data.fieldName)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Pack) InsertObjects(tx *sqlx.Tx) error {
|
||||||
|
relId := &InsertId[string]{id: p.ID, fieldName: "pack_id"}
|
||||||
|
syncDB := NewSyncDB()
|
||||||
|
defer close(syncDB.errChan)
|
||||||
|
|
||||||
|
InsertWithCtxParallel(syncDB, tx, p.Ownership, relId)
|
||||||
|
InsertSliceParallel(syncDB, tx, p.Index, relId)
|
||||||
|
InsertSliceParallel(syncDB, tx, p.Folders, relId)
|
||||||
|
|
||||||
|
return syncDB.Wait()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Pack) Insert(tx *sqlx.Tx, data *InsertId[string]) error {
|
||||||
|
if data.query == "" {
|
||||||
|
return ErrNoQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
args := []any{data.id, p.ID, p.Name, p.Label, p.Banner, p.Path, p.Type, p.System, p.PackageType, p.PackageName}
|
||||||
|
|
||||||
|
_, err := tx.Exec(data.query, args...)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return p.InsertObjects(tx)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Pack) InsertCtx(ctx context.Context, tx *sqlx.Tx, data *InsertId[string]) error {
|
||||||
|
if data.query == "" {
|
||||||
|
return ErrNoQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
args := []any{data.id, p.ID, p.Name, p.Label, p.Banner, p.Path, p.Type, p.System, p.PackageType, p.PackageName}
|
||||||
|
|
||||||
|
_, err := tx.ExecContext(ctx, data.query, args...)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return p.InsertObjects(tx)
|
||||||
}
|
}
|
||||||
|
|
||||||
type PackFolder struct {
|
type PackFolder struct {
|
||||||
@@ -21,7 +77,43 @@ type PackFolder struct {
|
|||||||
|
|
||||||
Description string
|
Description string
|
||||||
Name string
|
Name string
|
||||||
Sort int
|
|
||||||
Sorting string
|
Sorting string
|
||||||
Type string
|
Type string
|
||||||
|
Sort int
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PackFolder) Query(data *InsertId[string]) {
|
||||||
|
data.query = fmt.Sprintf(`
|
||||||
|
INSERT INTO pack_folder (%s, id, description, name, sorting, type, sort)
|
||||||
|
VALUES ($1, $2, $3, $4, $5, $6, $7)`, data.fieldName)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PackFolder) Insert(tx *sqlx.Tx, data *InsertId[string]) error {
|
||||||
|
if data.query == "" {
|
||||||
|
return ErrNoQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
args := []any{data.id, p.ID, p.Description, p.Name, p.Sorting, p.Type, p.Sort}
|
||||||
|
|
||||||
|
_, err := tx.Exec(data.query, args...)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PackFolder) InsertCtx(ctx context.Context, tx *sqlx.Tx, data *InsertId[string]) error {
|
||||||
|
if data.query == "" {
|
||||||
|
return ErrNoQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
args := []any{data.id, p.ID, p.Description, p.Name, p.Sorting, p.Type, p.Sort}
|
||||||
|
|
||||||
|
_, err := tx.ExecContext(ctx, data.query, args...)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,99 +7,106 @@ import (
|
|||||||
"github.com/jmoiron/sqlx"
|
"github.com/jmoiron/sqlx"
|
||||||
)
|
)
|
||||||
|
|
||||||
type PackageWarningsData struct {
|
|
||||||
ID string
|
|
||||||
|
|
||||||
Type string
|
|
||||||
Warning []string
|
|
||||||
Error []string
|
|
||||||
Reinstallable bool
|
|
||||||
Manifest string
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PackageWarningsData) InsertSliceType(tx *sqlx.Tx, data *InsertId[string], sliceType string) error {
|
|
||||||
query := fmt.Sprintf(`
|
|
||||||
INSERT INTO package_warnings_data (%s, id, type, reinstallable, manifest)
|
|
||||||
VALUES ($1, $2, $3, $4, $5)`, data.fieldName)
|
|
||||||
|
|
||||||
args := []any{data.id, p.ID, p.Type, p.Reinstallable, p.Manifest}
|
|
||||||
|
|
||||||
_, err := tx.Exec(query, args...)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PackageWarningsData) Insert(tx *sqlx.Tx, data *InsertId[string]) error {
|
|
||||||
query := fmt.Sprintf(`
|
|
||||||
INSERT INTO package_warnings_data (%s, id, type, reinstallable, manifest)
|
|
||||||
VALUES ($1, $2, $3, $4, $5)`, data.fieldName)
|
|
||||||
|
|
||||||
args := []any{data.id, p.ID, p.Type, p.Reinstallable, p.Manifest}
|
|
||||||
|
|
||||||
_, err := tx.Exec(query, args...)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PackageWarningsData) InsertCtx(ctx context.Context, tx *sqlx.Tx, data *InsertId[string]) error {
|
|
||||||
query := fmt.Sprintf(`
|
|
||||||
INSERT INTO package_warnings_data (%s, id, type, reinstallable, manifest)
|
|
||||||
VALUES ($1, $2, $3, $4, $5)
|
|
||||||
RETURNING id`, data.fieldName)
|
|
||||||
|
|
||||||
args := []any{data.id, p.ID, p.Type, p.Reinstallable, p.Manifest}
|
|
||||||
|
|
||||||
_, err := tx.ExecContext(ctx, query, args...)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type PackageWarning struct {
|
type PackageWarning struct {
|
||||||
ID string
|
ID string
|
||||||
|
|
||||||
Key string
|
Key string
|
||||||
Value PackageWarningsData
|
Value *PackageWarningsData
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PackageWarning) Query(data *InsertId[uint]) {
|
||||||
|
data.query = fmt.Sprintf(`
|
||||||
|
INSERT INTO package_warnings (%s, id)
|
||||||
|
VALUES ($1, $2)`, data.fieldName)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PackageWarning) Insert(tx *sqlx.Tx, data *InsertId[uint]) error {
|
func (p *PackageWarning) Insert(tx *sqlx.Tx, data *InsertId[uint]) error {
|
||||||
query := fmt.Sprintf(`
|
if data.query == "" {
|
||||||
INSERT INTO package_warnings (%s, id)
|
return ErrNoQuery
|
||||||
VALUES ($1, $2)`, data.fieldName)
|
}
|
||||||
|
|
||||||
args := []any{data.id, p.ID}
|
args := []any{data.id, p.ID}
|
||||||
|
|
||||||
_, err := tx.Execx(query, args...)
|
_, err := tx.Exec(data.query, args...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
InsertWithCtx(tx, &p.Value, &InsertId[string]{id: p.ID})
|
InsertWithCtx(tx, p.Value, &InsertId[string]{id: p.ID})
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PackageWarning) InsertCtx(ctx context.Context, tx *sqlx.Tx, data *InsertId[uint]) error {
|
func (p *PackageWarning) InsertCtx(ctx context.Context, tx *sqlx.Tx, data *InsertId[uint]) error {
|
||||||
query := fmt.Sprintf(`
|
if data.query == "" {
|
||||||
INSERT INTO package_warnings (%s, id)
|
return ErrNoQuery
|
||||||
VALUES ($1, $2)`, data.fieldName)
|
}
|
||||||
|
|
||||||
args := []any{data.id, p.ID}
|
args := []any{data.id, p.ID}
|
||||||
|
|
||||||
_, err := tx.Exec(query, args...)
|
_, err := tx.Exec(data.query, args...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
InsertWithCtx(tx, &p.Value, &InsertId[string]{id: p.ID})
|
InsertWithCtx(tx, p.Value, &InsertId[string]{id: p.ID})
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type PackageWarningsData struct {
|
||||||
|
ID string
|
||||||
|
|
||||||
|
Type string
|
||||||
|
Manifest string
|
||||||
|
Reinstallable bool
|
||||||
|
Warning []string
|
||||||
|
Error []string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PackageWarningsData) InsertObjects(tx *sqlx.Tx) error {
|
||||||
|
syncDB := NewSyncDB()
|
||||||
|
defer close(syncDB.errChan)
|
||||||
|
warningData := &InsertId[string]{id: p.ID, fieldName: "package_warnings_data_id", tableName: "package_warnings_data_warning"}
|
||||||
|
InsertSimpleSliceParallel(syncDB, tx, p.Warning, warningData)
|
||||||
|
errorData := &InsertId[string]{id: p.ID, fieldName: "package_warnings_data_id", tableName: "package_warnings_data_error"}
|
||||||
|
InsertSimpleSliceParallel(syncDB, tx, p.Warning, errorData)
|
||||||
|
|
||||||
|
return syncDB.Wait()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PackageWarningsData) Query(data *InsertId[string]) {
|
||||||
|
data.query = fmt.Sprintf(`
|
||||||
|
INSERT INTO package_warnings_data (%s, id, type, reinstallable, manifest)
|
||||||
|
VALUES ($1, $2, $3, $4, $5)`, data.fieldName)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PackageWarningsData) Insert(tx *sqlx.Tx, data *InsertId[string]) error {
|
||||||
|
if data.query == "" {
|
||||||
|
return ErrNoQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
args := []any{data.id, p.ID, p.Type, p.Reinstallable, p.Manifest}
|
||||||
|
|
||||||
|
_, err := tx.Exec(data.query, args...)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return p.InsertObjects(tx)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PackageWarningsData) InsertCtx(ctx context.Context, tx *sqlx.Tx, data *InsertId[string]) error {
|
||||||
|
if data.query == "" {
|
||||||
|
return ErrNoQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
args := []any{data.id, p.ID, p.Type, p.Reinstallable, p.Manifest}
|
||||||
|
|
||||||
|
_, err := tx.ExecContext(ctx, data.query, args...)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return p.InsertObjects(tx)
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
package db
|
package db
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/jmoiron/sqlx"
|
||||||
|
)
|
||||||
|
|
||||||
type Relationships struct {
|
type Relationships struct {
|
||||||
ID uint
|
ID uint
|
||||||
|
|
||||||
@@ -9,11 +16,107 @@ type Relationships struct {
|
|||||||
Conflicts []RelationshipsData
|
Conflicts []RelationshipsData
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r Relationships) Query(data *InsertId[string]) {
|
||||||
|
data.query = fmt.Sprintf(`
|
||||||
|
INSERT INTO relationships (%s)
|
||||||
|
VALUES ($1)
|
||||||
|
RETURNING id`, data.fieldName)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r Relationships) Insert(tx *sqlx.Tx, data *InsertId[string]) error {
|
||||||
|
if data.query == "" {
|
||||||
|
return ErrNoQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
args := []any{data.id}
|
||||||
|
|
||||||
|
err := tx.QueryRowx(data.query, args...).Scan(&r.ID)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
syncDB := NewSyncDB()
|
||||||
|
defer close(syncDB.errChan)
|
||||||
|
|
||||||
|
InsertSliceParallel(syncDB, tx, r.Systems, &InsertId[uint]{id: r.ID, tableName: "relationships_systems"})
|
||||||
|
InsertSliceParallel(syncDB, tx, r.Requires, &InsertId[uint]{id: r.ID, tableName: "relationships_requires"})
|
||||||
|
InsertSliceParallel(syncDB, tx, r.Recommends, &InsertId[uint]{id: r.ID, tableName: "relationships_recommends"})
|
||||||
|
InsertSliceParallel(syncDB, tx, r.Conflicts, &InsertId[uint]{id: r.ID, tableName: "relationships_conflicts"})
|
||||||
|
|
||||||
|
return syncDB.Wait()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r Relationships) InsertCtx(ctx context.Context, tx *sqlx.Tx, data *InsertId[string]) error {
|
||||||
|
if data.query == "" {
|
||||||
|
return ErrNoQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
args := []any{data.id}
|
||||||
|
|
||||||
|
err := tx.QueryRowxContext(ctx, data.query, args...).Scan(&r.ID)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
syncDB := NewSyncDB()
|
||||||
|
defer close(syncDB.errChan)
|
||||||
|
|
||||||
|
InsertSliceParallel(syncDB, tx, r.Systems, &InsertId[uint]{id: r.ID, tableName: "relationships_systems"})
|
||||||
|
InsertSliceParallel(syncDB, tx, r.Requires, &InsertId[uint]{id: r.ID, tableName: "relationships_requires"})
|
||||||
|
InsertSliceParallel(syncDB, tx, r.Recommends, &InsertId[uint]{id: r.ID, tableName: "relationships_recommends"})
|
||||||
|
InsertSliceParallel(syncDB, tx, r.Conflicts, &InsertId[uint]{id: r.ID, tableName: "relationships_conflicts"})
|
||||||
|
|
||||||
|
return syncDB.Wait()
|
||||||
|
}
|
||||||
|
|
||||||
type RelationshipsData struct {
|
type RelationshipsData struct {
|
||||||
ID string
|
ID string
|
||||||
|
|
||||||
RelationshipsType string
|
|
||||||
Type string
|
Type string
|
||||||
Manifest string
|
Manifest string
|
||||||
Compatibility Compatibility
|
Compatibility Compatibility
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r RelationshipsData) Query(data *InsertId[uint]) {
|
||||||
|
data.query = fmt.Sprintf(`
|
||||||
|
INSERT INTO %s (relationships_id, id, type, manifest)
|
||||||
|
VALUES ($1, $2, $3, $4, $5)`, data.tableName)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r RelationshipsData) Insert(tx *sqlx.Tx, data *InsertId[uint]) error {
|
||||||
|
if data.query == "" {
|
||||||
|
return ErrNoQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
args := []any{data.id, r.ID, r.Type, r.Manifest}
|
||||||
|
|
||||||
|
_, err := tx.Exec(data.query, args...)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
syncDB := NewSyncDB()
|
||||||
|
defer close(syncDB.errChan)
|
||||||
|
InsertWithCtxParallel(syncDB, tx, r.Compatibility, &InsertId[string]{id: r.ID, fieldName: fmt.Sprintf("%s_id", data.tableName)})
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r RelationshipsData) InsertCtx(ctx context.Context, tx *sqlx.Tx, data *InsertId[uint]) error {
|
||||||
|
if data.query == "" {
|
||||||
|
return ErrNoQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
args := []any{data.id, r.ID, r.Type, r.Manifest}
|
||||||
|
|
||||||
|
_, err := tx.ExecContext(ctx, data.query, args...)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
syncDB := NewSyncDB()
|
||||||
|
defer close(syncDB.errChan)
|
||||||
|
InsertWithCtxParallel(syncDB, tx, r.Compatibility, &InsertId[string]{id: r.ID, fieldName: fmt.Sprintf("%s_id", data.tableName)})
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -20,15 +20,23 @@ type Release struct {
|
|||||||
Suffix string
|
Suffix string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Release) Insert(tx *sqlx.Tx, data *InsertId[uint]) error {
|
func (r *Release) Query(data *InsertId[uint]) {
|
||||||
query := fmt.Sprintf(`
|
data.query = fmt.Sprintf(`
|
||||||
INSERT INTO release_ (%s, generation, channel, suffix, build, node_version, max_generation, max_stable_generation, time)
|
INSERT INTO release_ (%s, generaion, build, node_version, max_generation, max_stable_generation,
|
||||||
|
time, channel, suffix)
|
||||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)
|
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)
|
||||||
RETURNING id`, data.fieldName)
|
RETURNING id`, data.fieldName)
|
||||||
|
}
|
||||||
|
|
||||||
args := []any{data.id, r.Generation, r.Channel, r.Suffix, r.Build, r.NodeVersion, r.MaxGeneration, r.MaxStableGeneration, r.Time}
|
func (r *Release) Insert(tx *sqlx.Tx, data *InsertId[uint]) error {
|
||||||
|
if data.query == "" {
|
||||||
|
return ErrNoQuery
|
||||||
|
}
|
||||||
|
|
||||||
err := tx.QueryRowx(query, args...).Scan(&r.ID)
|
args := []any{data.id, r.Generation, r.Build, r.NodeVersion, r.MaxGeneration, r.MaxStableGeneration,
|
||||||
|
r.Time, r.Channel, r.Suffix}
|
||||||
|
|
||||||
|
err := tx.QueryRowx(data.query, args...).Scan(&r.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -37,14 +45,14 @@ func (r *Release) Insert(tx *sqlx.Tx, data *InsertId[uint]) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *Release) InsertCtx(ctx context.Context, tx *sqlx.Tx, data *InsertId[uint]) error {
|
func (r *Release) InsertCtx(ctx context.Context, tx *sqlx.Tx, data *InsertId[uint]) error {
|
||||||
query := fmt.Sprintf(`
|
if data.query == "" {
|
||||||
INSERT INTO release_ (%s, generation, channel, suffix, build, node_version, max_generation, max_stable_generation, time)
|
return ErrNoQuery
|
||||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)
|
}
|
||||||
RETURNING id`, data.fieldName)
|
|
||||||
|
|
||||||
args := []any{data.id, r.Generation, r.Channel, r.Suffix, r.Build, r.NodeVersion, r.MaxGeneration, r.MaxStableGeneration, r.Time}
|
args := []any{data.id, r.Generation, r.Build, r.NodeVersion, r.MaxGeneration, r.MaxStableGeneration,
|
||||||
|
r.Time, r.Channel, r.Suffix}
|
||||||
|
|
||||||
err := tx.QueryRowxContext(ctx, query, args...).Scan(&r.ID)
|
err := tx.QueryRowxContext(ctx, data.query, args...).Scan(&r.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package db
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"sync"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/jmoiron/sqlx"
|
"github.com/jmoiron/sqlx"
|
||||||
@@ -14,19 +14,45 @@ type Setup struct {
|
|||||||
|
|
||||||
IsAdmin bool
|
IsAdmin bool
|
||||||
IsSetup bool
|
IsSetup bool
|
||||||
CoreUpdate CoreUpdate //+
|
CoreUpdate CoreUpdate
|
||||||
FeaturedContent FeaturedContent //+
|
FeaturedContent FeaturedContent
|
||||||
Files Files //+
|
Files Files
|
||||||
Options *SetupOptions //+
|
Options *SetupOptions
|
||||||
Release Release //+
|
Release Release
|
||||||
Languages []SetupLanguage //+
|
Languages []*SetupLanguage
|
||||||
Modules []*Module
|
Modules []*Module
|
||||||
News []News //+
|
News []*News
|
||||||
PackageWarnings []*PackageWarning
|
PackageWarnings []*PackageWarning
|
||||||
Systems []*System
|
Systems []*System
|
||||||
Worlds []*World
|
Worlds []*World
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Setup) InsertObjects(tx *sqlx.Tx) error {
|
||||||
|
relData := &InsertId[uint]{id: s.ID, fieldName: "setup_id"}
|
||||||
|
syncDB := NewSyncDB()
|
||||||
|
defer close(syncDB.errChan)
|
||||||
|
|
||||||
|
InsertWithCtxParallel(syncDB, tx, &s.CoreUpdate, relData)
|
||||||
|
InsertWithCtxParallel(syncDB, tx, &s.FeaturedContent, relData)
|
||||||
|
InsertWithCtxParallel(syncDB, tx, &s.Files, relData)
|
||||||
|
InsertWithCtxParallel(syncDB, tx, s.Options, relData)
|
||||||
|
InsertWithCtxParallel(syncDB, tx, &s.Release, relData)
|
||||||
|
|
||||||
|
InsertSliceParallel(syncDB, tx, s.Languages, relData)
|
||||||
|
InsertSliceParallel(syncDB, tx, s.Modules, relData)
|
||||||
|
InsertSliceParallel(syncDB, tx, s.News, relData)
|
||||||
|
InsertSliceParallel(syncDB, tx, s.PackageWarnings, relData)
|
||||||
|
|
||||||
|
relDataString := &InsertId[string]{
|
||||||
|
id: strconv.FormatUint(uint64(s.ID), 10),
|
||||||
|
fieldName: "setup_id",
|
||||||
|
}
|
||||||
|
InsertSliceParallel(syncDB, tx, s.Systems, relDataString)
|
||||||
|
InsertSliceParallel(syncDB, tx, s.Worlds, relDataString)
|
||||||
|
|
||||||
|
return syncDB.Wait()
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Setup) Insert(db *sqlx.DB) error {
|
func (s *Setup) Insert(db *sqlx.DB) error {
|
||||||
tx := db.MustBegin()
|
tx := db.MustBegin()
|
||||||
defer tx.Rollback()
|
defer tx.Rollback()
|
||||||
@@ -45,23 +71,8 @@ func (s *Setup) Insert(db *sqlx.DB) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
id := InsertId[uint]{id: s.ID, fieldName: "setup_id"}
|
|
||||||
|
|
||||||
dataSync := SyncDbOperations{
|
err = s.InsertObjects(tx)
|
||||||
wg: sync.WaitGroup{},
|
|
||||||
errChan: make(chan error),
|
|
||||||
}
|
|
||||||
defer close(dataSync.errChan)
|
|
||||||
|
|
||||||
go InsertSliceParallel(&dataSync, tx, s.News, &id)
|
|
||||||
go InsertSliceParallel(&dataSync, tx, s.Languages, &id)
|
|
||||||
|
|
||||||
InsertWithCtx(tx, &s.FeaturedContent, &id)
|
|
||||||
InsertWithCtx(tx, &s.Files, &id)
|
|
||||||
InsertWithCtx(tx, &s.Release, &id)
|
|
||||||
InsertWithCtx(tx, &s.CoreUpdate, &id)
|
|
||||||
|
|
||||||
err = dataSync.Wait()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -78,15 +89,21 @@ type FeaturedContent struct {
|
|||||||
Image string
|
Image string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FeaturedContent) Insert(tx *sqlx.Tx, setup *InsertId[uint]) error {
|
func (f *FeaturedContent) Query(data *InsertId[uint]) {
|
||||||
const query = `
|
data.query = `
|
||||||
INSERT INTO featured_content (setup_id, title, caption, url, image)
|
INSERT INTO featured_content (setup_id, title, caption, url, image)
|
||||||
VALUES ($1, $2, $3, $4, $5)
|
VALUES ($1, $2, $3, $4, $5)
|
||||||
RETURNING id`
|
RETURNING id`
|
||||||
|
}
|
||||||
|
|
||||||
args := []any{setup.id, f.Title, f.Caption, f.URL, f.Image}
|
func (f *FeaturedContent) Insert(tx *sqlx.Tx, data *InsertId[uint]) error {
|
||||||
|
if data.query == "" {
|
||||||
|
return ErrNoQuery
|
||||||
|
}
|
||||||
|
|
||||||
err := tx.QueryRowx(query, args...).Scan(&f.ID)
|
args := []any{data.id, f.Title, f.Caption, f.URL, f.Image}
|
||||||
|
|
||||||
|
err := tx.QueryRowx(data.query, args...).Scan(&f.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -94,15 +111,14 @@ func (f *FeaturedContent) Insert(tx *sqlx.Tx, setup *InsertId[uint]) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FeaturedContent) InsertCtx(ctx context.Context, tx *sqlx.Tx, setup *InsertId[uint]) error {
|
func (f *FeaturedContent) InsertCtx(ctx context.Context, tx *sqlx.Tx, data *InsertId[uint]) error {
|
||||||
const query = `
|
if data.query == "" {
|
||||||
INSERT INTO featured_content (setup_id, title, caption, url, image)
|
return ErrNoQuery
|
||||||
VALUES ($1, $2, $3, $4, $5)
|
}
|
||||||
RETURNING id`
|
|
||||||
|
|
||||||
args := []any{setup.id, f.Title, f.Caption, f.URL, f.Image}
|
args := []any{data.id, f.Title, f.Caption, f.URL, f.Image}
|
||||||
|
|
||||||
err := tx.QueryRowxContext(ctx, query, args...).Scan(&f.ID)
|
err := tx.QueryRowxContext(ctx, data.query, args...).Scan(&f.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -119,15 +135,21 @@ type News struct {
|
|||||||
Image string
|
Image string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n News) Insert(tx *sqlx.Tx, setup *InsertId[uint]) error {
|
func (n *News) Query(data *InsertId[uint]) {
|
||||||
const insertNews = `
|
data.query = `
|
||||||
INSERT INTO news (setup_id, title, caption, url, image)
|
INSERT INTO news (setup_id, title, caption, url, image)
|
||||||
VALUES ($1, $2, $3, $4, $5)
|
VALUES ($1, $2, $3, $4, $5)
|
||||||
RETURNING id`
|
RETURNING id`
|
||||||
|
}
|
||||||
|
|
||||||
args := []any{setup.id, n.Title, n.Caption, n.URL, n.Image}
|
func (n *News) Insert(tx *sqlx.Tx, data *InsertId[uint]) error {
|
||||||
|
if data.query == "" {
|
||||||
|
return ErrNoQuery
|
||||||
|
}
|
||||||
|
|
||||||
err := tx.QueryRow(insertNews, args...).Scan(&n.ID)
|
args := []any{data.id, n.Title, n.Caption, n.URL, n.Image}
|
||||||
|
|
||||||
|
err := tx.QueryRow(data.query, args...).Scan(&n.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -135,15 +157,14 @@ func (n News) Insert(tx *sqlx.Tx, setup *InsertId[uint]) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n News) InsertCtx(ctx context.Context, tx *sqlx.Tx, setup *InsertId[uint]) error {
|
func (n *News) InsertCtx(ctx context.Context, tx *sqlx.Tx, data *InsertId[uint]) error {
|
||||||
const insertNews = `
|
if data.query == "" {
|
||||||
INSERT INTO news (setup_id, title, caption, url, image)
|
return ErrNoQuery
|
||||||
VALUES ($1, $2, $3, $4, $5)
|
}
|
||||||
RETURNING id`
|
|
||||||
|
|
||||||
args := []any{setup.id, n.Title, n.Caption, n.URL, n.Image}
|
args := []any{data.id, n.Title, n.Caption, n.URL, n.Image}
|
||||||
|
|
||||||
err := tx.QueryRowContext(ctx, insertNews, args...).Scan(&n.ID)
|
err := tx.QueryRowContext(ctx, data.query, args...).Scan(&n.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,51 @@
|
|||||||
package db
|
package db
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/jmoiron/sqlx"
|
||||||
|
)
|
||||||
|
|
||||||
type Style struct {
|
type Style struct {
|
||||||
ID uint
|
ID uint
|
||||||
|
|
||||||
Src string
|
Src string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Style) Query(data *InsertId[string]) {
|
||||||
|
data.query = fmt.Sprintf(`
|
||||||
|
INSERT INTO style (%s, src)
|
||||||
|
VALUES ($1, $2)
|
||||||
|
RETURNING id`, data.fieldName)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Style) Insert(tx *sqlx.Tx, data *InsertId[string]) error {
|
||||||
|
if data.query == "" {
|
||||||
|
return ErrNoQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
args := []any{data.id, s.Src}
|
||||||
|
|
||||||
|
err := tx.QueryRow(data.query, args...).Scan(&s.ID)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Style) InsertCtx(ctx context.Context, tx *sqlx.Tx, data *InsertId[string]) error {
|
||||||
|
if data.query == "" {
|
||||||
|
return ErrNoQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
args := []any{data.id, s.Src}
|
||||||
|
|
||||||
|
err := tx.QueryRowContext(ctx, data.query, args...).Scan(&s.ID)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
package db
|
package db
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/jmoiron/sqlx"
|
||||||
|
)
|
||||||
|
|
||||||
type System struct {
|
type System struct {
|
||||||
ID string
|
ID string
|
||||||
|
|
||||||
@@ -10,29 +17,101 @@ type System struct {
|
|||||||
Bugs string
|
Bugs string
|
||||||
Changelog string
|
Changelog string
|
||||||
Version string
|
Version string
|
||||||
Socket bool
|
|
||||||
Manifest string
|
Manifest string
|
||||||
Download string
|
Download string
|
||||||
Protected bool
|
|
||||||
Exclusive bool
|
|
||||||
PersistentStorage bool
|
|
||||||
Background string
|
Background string
|
||||||
PrimaryTokenAttribute string
|
PrimaryTokenAttribute string
|
||||||
Availability int
|
Availability int
|
||||||
|
Socket bool
|
||||||
|
Protected bool
|
||||||
|
Exclusive bool
|
||||||
|
PersistentStorage bool
|
||||||
Locked bool
|
Locked bool
|
||||||
Owned bool
|
Owned bool
|
||||||
HasStorage bool
|
HasStorage bool
|
||||||
Esmodules []string
|
|
||||||
Scripts []string
|
|
||||||
Tags []string
|
|
||||||
Compatibility Compatibility
|
Compatibility Compatibility
|
||||||
Relationships Relationships
|
Relationships Relationships
|
||||||
DocumentTypes DocumentTypes
|
DocumentTypes DocumentTypes
|
||||||
Grid Grid
|
Grid *Grid
|
||||||
Authors []Author
|
Esmodules []string
|
||||||
Media []Media
|
Scripts []string
|
||||||
Packs []Pack
|
Tags []string
|
||||||
Styles []Style
|
Authors []*Author
|
||||||
Languages []Language
|
Media []*Media
|
||||||
PackFolders []Folder
|
Packs []*Pack
|
||||||
|
Styles []*Style
|
||||||
|
Languages []*Language
|
||||||
|
PackFolders []*Folder
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *System) Query(data *InsertId[string]) {
|
||||||
|
data.query = fmt.Sprintf(`
|
||||||
|
INSERT INTO system (%s, id, title, description, url, license, bugs, changelog, version, manifest,
|
||||||
|
download, background, primary_token_attribute, availability, socket, protected, exclusive_,
|
||||||
|
persistent_storage, locked, owned, has_storage)
|
||||||
|
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21)`,
|
||||||
|
data.fieldName)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *System) InsertObjects(tx *sqlx.Tx) error {
|
||||||
|
relId := &InsertId[string]{id: s.ID, fieldName: "system_id"}
|
||||||
|
syncDB := NewSyncDB()
|
||||||
|
defer close(syncDB.errChan)
|
||||||
|
|
||||||
|
InsertWithCtxParallel(syncDB, tx, s.Compatibility, relId)
|
||||||
|
InsertWithCtxParallel(syncDB, tx, s.Relationships, relId)
|
||||||
|
InsertWithCtxParallel(syncDB, tx, s.DocumentTypes, relId)
|
||||||
|
InsertWithCtxParallel(syncDB, tx, s.Grid, relId)
|
||||||
|
|
||||||
|
esModulesRelId := &InsertId[string]{id: s.ID, fieldName: "system_id", tableName: "es_modules"}
|
||||||
|
InsertSimpleSliceParallel(syncDB, tx, s.Esmodules, esModulesRelId)
|
||||||
|
scriptRelId := &InsertId[string]{id: s.ID, fieldName: "system_id", tableName: "scripts"}
|
||||||
|
InsertSimpleSliceParallel(syncDB, tx, s.Scripts, scriptRelId)
|
||||||
|
tagsRelId := &InsertId[string]{id: s.ID, fieldName: "system_id", tableName: "tags"}
|
||||||
|
InsertSimpleSliceParallel(syncDB, tx, s.Tags, tagsRelId)
|
||||||
|
|
||||||
|
InsertSliceParallel(syncDB, tx, s.Authors, relId)
|
||||||
|
InsertSliceParallel(syncDB, tx, s.Media, relId)
|
||||||
|
InsertSliceParallel(syncDB, tx, s.Styles, relId)
|
||||||
|
InsertSliceParallel(syncDB, tx, s.Languages, relId)
|
||||||
|
InsertSliceParallel(syncDB, tx, s.Packs, relId)
|
||||||
|
InsertSliceParallel(syncDB, tx, s.PackFolders, relId)
|
||||||
|
|
||||||
|
return syncDB.Wait()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *System) Insert(tx *sqlx.Tx, data *InsertId[string]) error {
|
||||||
|
if data.query == "" {
|
||||||
|
return ErrNoQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
args := []any{data.id, s.ID, s.Title, s.Description, s.URL, s.License, s.Bugs,
|
||||||
|
s.Changelog, s.Version, s.Manifest, s.Download, s.Background,
|
||||||
|
s.PrimaryTokenAttribute, s.Availability, s.Socket, s.Protected, s.Exclusive,
|
||||||
|
s.PersistentStorage, s.Locked, s.Owned, s.HasStorage}
|
||||||
|
|
||||||
|
_, err := tx.Exec(data.query, args...)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.InsertObjects(tx)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *System) InsertCtx(ctx context.Context, tx *sqlx.Tx, data *InsertId[string]) error {
|
||||||
|
if data.query == "" {
|
||||||
|
return ErrNoQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
args := []any{data.id, s.ID, s.Title, s.Description, s.URL, s.License, s.Bugs,
|
||||||
|
s.Changelog, s.Version, s.Manifest, s.Download, s.Background,
|
||||||
|
s.PrimaryTokenAttribute, s.Availability, s.Socket, s.Protected, s.Exclusive,
|
||||||
|
s.PersistentStorage, s.Locked, s.Owned, s.HasStorage}
|
||||||
|
|
||||||
|
_, err := tx.ExecContext(ctx, data.query, args...)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.InsertObjects(tx)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,20 +14,26 @@ type CoreUpdate struct {
|
|||||||
CanUpdate bool
|
CanUpdate bool
|
||||||
CouldReachWebsite bool
|
CouldReachWebsite bool
|
||||||
SlowResponse bool
|
SlowResponse bool
|
||||||
|
WillDisableModules bool
|
||||||
Version string
|
Version string
|
||||||
Channel string
|
Channel string
|
||||||
WillDisableModules bool
|
}
|
||||||
|
|
||||||
|
func (c *CoreUpdate) Query(data *InsertId[uint]) {
|
||||||
|
data.query = fmt.Sprintf(`
|
||||||
|
INSERT INTO core_update (%s, has_update, can_update, could_reach_website, slow_response, will_disable_modules, version, channel)
|
||||||
|
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
|
||||||
|
RETURNING id`, data.fieldName)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *CoreUpdate) Insert(tx *sqlx.Tx, data *InsertId[uint]) error {
|
func (c *CoreUpdate) Insert(tx *sqlx.Tx, data *InsertId[uint]) error {
|
||||||
query := fmt.Sprintf(`
|
if data.query == "" {
|
||||||
INSERT INTO core_update (%s, has_update, can_update, could_reach_website, slow_response, version, channel, will_disable_modules)
|
return ErrNoQuery
|
||||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
|
}
|
||||||
RETURNING id`, data.fieldName)
|
|
||||||
|
|
||||||
args := []any{data.id, c.HasUpdate, c.CanUpdate, c.CouldReachWebsite, c.SlowResponse, c.Version, c.Channel, c.WillDisableModules}
|
args := []any{data.id, c.HasUpdate, c.CanUpdate, c.CouldReachWebsite, c.SlowResponse, c.WillDisableModules, c.Version, c.Channel}
|
||||||
|
|
||||||
err := tx.QueryRowx(query, args...).Scan(&c.ID)
|
err := tx.QueryRowx(data.query, args...).Scan(&c.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -36,14 +42,13 @@ func (c *CoreUpdate) Insert(tx *sqlx.Tx, data *InsertId[uint]) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *CoreUpdate) InsertCtx(ctx context.Context, tx *sqlx.Tx, data *InsertId[uint]) error {
|
func (c *CoreUpdate) InsertCtx(ctx context.Context, tx *sqlx.Tx, data *InsertId[uint]) error {
|
||||||
query := fmt.Sprintf(`
|
if data.query == "" {
|
||||||
INSERT INTO core_update (%s, has_update, can_update, could_reach_website, slow_response, version, channel, will_disable_modules)
|
return ErrNoQuery
|
||||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
|
}
|
||||||
RETURNING id`, data.fieldName)
|
|
||||||
|
|
||||||
args := []any{data.id, c.HasUpdate, c.CanUpdate, c.CouldReachWebsite, c.SlowResponse, c.Version, c.Channel, c.WillDisableModules}
|
args := []any{data.id, c.HasUpdate, c.CanUpdate, c.CouldReachWebsite, c.SlowResponse, c.WillDisableModules, c.Version, c.Channel}
|
||||||
|
|
||||||
err := tx.QueryRowxContext(ctx, query, args...).Scan(&c.ID)
|
err := tx.QueryRowxContext(ctx, data.query, args...).Scan(&c.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package db
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
@@ -9,6 +10,10 @@ import (
|
|||||||
"github.com/jmoiron/sqlx"
|
"github.com/jmoiron/sqlx"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
ErrNoQuery = errors.New("Query has not been set")
|
||||||
|
)
|
||||||
|
|
||||||
type AllowedIds interface {
|
type AllowedIds interface {
|
||||||
~uint | ~string
|
~uint | ~string
|
||||||
}
|
}
|
||||||
@@ -17,14 +22,22 @@ type InsertId[T AllowedIds] struct {
|
|||||||
id T
|
id T
|
||||||
fieldName string
|
fieldName string
|
||||||
tableName string
|
tableName string
|
||||||
|
query string
|
||||||
}
|
}
|
||||||
|
|
||||||
type SyncDbOperations struct {
|
type SyncDB struct {
|
||||||
errChan chan error
|
errChan chan error
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SyncDbOperations) Wait() error {
|
func NewSyncDB() *SyncDB {
|
||||||
|
return &SyncDB{
|
||||||
|
wg: sync.WaitGroup{},
|
||||||
|
errChan: make(chan error),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *SyncDB) Wait() error {
|
||||||
return WaitSync(&s.wg, s.errChan)
|
return WaitSync(&s.wg, s.errChan)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,6 +59,7 @@ func WaitSync(wg *sync.WaitGroup, errChan chan error) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Insertable[T AllowedIds] interface {
|
type Insertable[T AllowedIds] interface {
|
||||||
|
Query(data *InsertId[T])
|
||||||
Insert(tx *sqlx.Tx, relId *InsertId[T]) error
|
Insert(tx *sqlx.Tx, relId *InsertId[T]) error
|
||||||
InsertCtx(ctx context.Context, tx *sqlx.Tx, relId *InsertId[T]) error
|
InsertCtx(ctx context.Context, tx *sqlx.Tx, relId *InsertId[T]) error
|
||||||
}
|
}
|
||||||
@@ -54,13 +68,30 @@ func InsertWithCtx[T AllowedIds, I Insertable[T]](tx *sqlx.Tx, data I, relId *In
|
|||||||
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
|
data.Query(relId)
|
||||||
return data.InsertCtx(ctx, tx, relId)
|
return data.InsertCtx(ctx, tx, relId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func InsertWithCtxParallel[T AllowedIds, I Insertable[T]](syncDb *SyncDB, tx *sqlx.Tx, data I, relId *InsertId[T]) {
|
||||||
|
syncDb.wg.Go(func() {
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
data.Query(relId)
|
||||||
|
err := data.InsertCtx(ctx, tx, relId)
|
||||||
|
if err != nil {
|
||||||
|
syncDb.errChan <- err
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func InsertSlice[T AllowedIds, I Insertable[T]](tx *sqlx.Tx, data []I, relId *InsertId[T]) error {
|
func InsertSlice[T AllowedIds, I Insertable[T]](tx *sqlx.Tx, data []I, relId *InsertId[T]) error {
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
|
if len(data) > 0 {
|
||||||
|
data[0].Query(relId)
|
||||||
|
}
|
||||||
for i := range data {
|
for i := range data {
|
||||||
err := data[i].InsertCtx(ctx, tx, relId)
|
err := data[i].InsertCtx(ctx, tx, relId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -70,41 +101,42 @@ func InsertSlice[T AllowedIds, I Insertable[T]](tx *sqlx.Tx, data []I, relId *In
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func InsertSliceParallel[T AllowedIds, I Insertable[T]](syncDb *SyncDbOperations, tx *sqlx.Tx, data []I, relId *InsertId[T]) {
|
func InsertSliceParallel[T AllowedIds, I Insertable[T]](syncDb *SyncDB, tx *sqlx.Tx, data []I, relId *InsertId[T]) {
|
||||||
syncDb.wg.Add(1)
|
syncDb.wg.Go(func() {
|
||||||
|
|
||||||
wg := sync.WaitGroup{}
|
wg := sync.WaitGroup{}
|
||||||
errChan := make(chan error)
|
errChan := make(chan error)
|
||||||
defer close(errChan)
|
defer close(errChan)
|
||||||
|
|
||||||
|
var err error
|
||||||
|
if len(data) > 0 {
|
||||||
|
data[0].Query(relId)
|
||||||
|
}
|
||||||
for i := range data {
|
for i := range data {
|
||||||
go func() {
|
wg.Go(func() {
|
||||||
wg.Add(1)
|
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
errChan <- data[i].InsertCtx(ctx, tx, relId)
|
err = data[i].InsertCtx(ctx, tx, relId)
|
||||||
|
if err != nil {
|
||||||
wg.Done()
|
errChan <- err
|
||||||
}()
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
err := WaitSync(&wg, errChan)
|
err = WaitSync(&wg, errChan)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
syncDb.errChan <- err
|
syncDb.errChan <- err
|
||||||
}
|
}
|
||||||
syncDb.wg.Done()
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func InsertSimpleSliceToTable[T AllowedIds, I Insertable[T]](tx *sqlx.Tx, data []I, relId *InsertId[T]) error {
|
func InsertSimpleSlice[T AllowedIds, I any](tx *sqlx.Tx, data []I, relId *InsertId[T]) error {
|
||||||
query := fmt.Sprintf(`
|
|
||||||
INSERT INTO %s (%s, value)
|
|
||||||
VALUES (:id, :value)`, relId.tableName, relId.fieldName)
|
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
|
query := fmt.Sprintf(`
|
||||||
|
INSERT INTO %s (%s, value)
|
||||||
|
VALUES ($1, $2)`, relId.tableName, relId.fieldName)
|
||||||
for i := range data {
|
for i := range data {
|
||||||
_, err := tx.ExecContext(ctx, query, relId.id, data[i])
|
_, err := tx.ExecContext(ctx, query, relId.id, data[i])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -114,3 +146,31 @@ func InsertSimpleSliceToTable[T AllowedIds, I Insertable[T]](tx *sqlx.Tx, data [
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func InsertSimpleSliceParallel[T AllowedIds, I any](syncDb *SyncDB, tx *sqlx.Tx, data []I, relId *InsertId[T]) {
|
||||||
|
syncDb.wg.Go(func() {
|
||||||
|
wg := sync.WaitGroup{}
|
||||||
|
errChan := make(chan error)
|
||||||
|
defer close(errChan)
|
||||||
|
|
||||||
|
query := fmt.Sprintf(`
|
||||||
|
INSERT INTO %s (%s, value)
|
||||||
|
VALUES ($1, $2)`, relId.tableName, relId.fieldName)
|
||||||
|
for i := range data {
|
||||||
|
wg.Go(func() {
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
_, err := tx.ExecContext(ctx, query, relId.id, data[i])
|
||||||
|
if err != nil {
|
||||||
|
errChan <- err
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
err := WaitSync(&wg, errChan)
|
||||||
|
if err != nil {
|
||||||
|
syncDb.errChan <- err
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,20 +1,16 @@
|
|||||||
package db
|
package db
|
||||||
|
|
||||||
import "time"
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/jmoiron/sqlx"
|
||||||
|
)
|
||||||
|
|
||||||
type World struct {
|
type World struct {
|
||||||
ID string
|
ID string
|
||||||
|
|
||||||
Socket bool
|
|
||||||
Protected bool
|
|
||||||
Exclusive bool
|
|
||||||
PersistentStorage bool
|
|
||||||
Locked bool
|
|
||||||
Owned bool
|
|
||||||
HasStorage bool
|
|
||||||
Playtime int
|
|
||||||
Availability int
|
|
||||||
NextSession time.Time
|
|
||||||
Title string
|
Title string
|
||||||
Description string
|
Description string
|
||||||
Version string
|
Version string
|
||||||
@@ -24,15 +20,93 @@ type World struct {
|
|||||||
CoreVersion string
|
CoreVersion string
|
||||||
SystemVersion string
|
SystemVersion string
|
||||||
LastPlayed string
|
LastPlayed string
|
||||||
|
Playtime int
|
||||||
|
Availability int
|
||||||
|
NextSession time.Time
|
||||||
|
Socket bool
|
||||||
|
Protected bool
|
||||||
|
Exclusive bool
|
||||||
|
PersistentStorage bool
|
||||||
|
Locked bool
|
||||||
|
Owned bool
|
||||||
|
HasStorage bool
|
||||||
|
Compatibility Compatibility
|
||||||
|
Relationships Relationships
|
||||||
Tags []string
|
Tags []string
|
||||||
Scripts []string
|
Scripts []string
|
||||||
Esmodules []string
|
Esmodules []string
|
||||||
Compatibility Compatibility
|
Authors []*Author
|
||||||
Relationships Relationships
|
Media []*Media
|
||||||
Authors []Author
|
Styles []*Style
|
||||||
Media []Media
|
Languages []*Language
|
||||||
Styles []Style
|
Packs []*Pack
|
||||||
Languages []Language
|
PackFolders []*Folder
|
||||||
Packs []Pack
|
}
|
||||||
PackFolders []Folder
|
|
||||||
|
func (w *World) Query(data *InsertId[string]) {
|
||||||
|
data.query = fmt.Sprintf(`
|
||||||
|
INSERT INTO world (%s, id, title, description, version, system, background, join_theme,
|
||||||
|
core_version, system_version, last_played, playtime, availability, next_session, socket,
|
||||||
|
protected, exclusive_, persistent_storage, locked, owned, has_storage)
|
||||||
|
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21)`,
|
||||||
|
data.fieldName)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *World) InsertObjects(tx *sqlx.Tx) error {
|
||||||
|
relId := &InsertId[string]{id: w.ID, fieldName: "world_id"}
|
||||||
|
syncDB := NewSyncDB()
|
||||||
|
defer close(syncDB.errChan)
|
||||||
|
|
||||||
|
InsertWithCtxParallel(syncDB, tx, w.Compatibility, relId)
|
||||||
|
InsertWithCtxParallel(syncDB, tx, w.Relationships, relId)
|
||||||
|
|
||||||
|
esModulesRelId := &InsertId[string]{id: w.ID, fieldName: "world_id", tableName: "es_modules"}
|
||||||
|
InsertSimpleSliceParallel(syncDB, tx, w.Esmodules, esModulesRelId)
|
||||||
|
scriptRelId := &InsertId[string]{id: w.ID, fieldName: "world_id", tableName: "scripts"}
|
||||||
|
InsertSimpleSliceParallel(syncDB, tx, w.Scripts, scriptRelId)
|
||||||
|
tagsRelId := &InsertId[string]{id: w.ID, fieldName: "world_id", tableName: "tags"}
|
||||||
|
InsertSimpleSliceParallel(syncDB, tx, w.Tags, tagsRelId)
|
||||||
|
|
||||||
|
InsertSliceParallel(syncDB, tx, w.Authors, relId)
|
||||||
|
InsertSliceParallel(syncDB, tx, w.Media, relId)
|
||||||
|
InsertSliceParallel(syncDB, tx, w.Styles, relId)
|
||||||
|
InsertSliceParallel(syncDB, tx, w.Languages, relId)
|
||||||
|
InsertSliceParallel(syncDB, tx, w.Packs, relId)
|
||||||
|
InsertSliceParallel(syncDB, tx, w.PackFolders, relId)
|
||||||
|
|
||||||
|
return syncDB.Wait()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *World) Insert(tx *sqlx.Tx, data *InsertId[string]) error {
|
||||||
|
if data.query == "" {
|
||||||
|
return ErrNoQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
args := []any{data.id, w.ID, w.Title, w.Description, w.Version, w.System, w.Background, w.JoinTheme,
|
||||||
|
w.CoreVersion, w.SystemVersion, w.LastPlayed, w.Playtime, w.Availability, w.NextSession, w.Socket,
|
||||||
|
w.Protected, w.Exclusive, w.PersistentStorage, w.Locked, w.Owned, w.HasStorage}
|
||||||
|
|
||||||
|
_, err := tx.Exec(data.query, args...)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return w.InsertObjects(tx)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *World) InsertCtx(ctx context.Context, tx *sqlx.Tx, data *InsertId[string]) error {
|
||||||
|
if data.query == "" {
|
||||||
|
return ErrNoQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
args := []any{data.id, w.ID, w.Title, w.Description, w.Version, w.System, w.Background, w.JoinTheme,
|
||||||
|
w.CoreVersion, w.SystemVersion, w.LastPlayed, w.Playtime, w.Availability, w.NextSession, w.Socket,
|
||||||
|
w.Protected, w.Exclusive, w.PersistentStorage, w.Locked, w.Owned, w.HasStorage}
|
||||||
|
|
||||||
|
_, err := tx.ExecContext(ctx, data.query, args...)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return w.InsertObjects(tx)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,15 +10,19 @@ type Author struct {
|
|||||||
// SystemAuthorsFlags SystemAuthorsFlags `json:"flags"`
|
// SystemAuthorsFlags SystemAuthorsFlags `json:"flags"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Author) ToDB(dest *db.Author) bool {
|
func (a *Author) ToDB(dest **db.Author) bool {
|
||||||
if dest == nil {
|
if dest == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
dest.Name = a.Name
|
author := &db.Author{
|
||||||
dest.URL = a.URL
|
Name: a.Name,
|
||||||
dest.Email = a.Email
|
URL: a.URL,
|
||||||
dest.Discord = a.Discord
|
Email: a.Email,
|
||||||
|
Discord: a.Discord,
|
||||||
|
}
|
||||||
|
|
||||||
|
*dest = author
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,12 +13,12 @@ func (d *DocumentTypes) ToDB(dest *db.DocumentTypes) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
dest.Data = make([]db.DocumentTypeData, 2)
|
dest.Data = make([]*db.DocumentTypeData, 2)
|
||||||
|
|
||||||
d.Actor.ToDB(&dest.Data[0])
|
d.Actor.ToDB(dest.Data[0])
|
||||||
dest.Data[0].Type = "Actor"
|
dest.Data[0].Type = "Actor"
|
||||||
|
|
||||||
d.Item.ToDB(&dest.Data[1])
|
d.Item.ToDB(dest.Data[1])
|
||||||
dest.Data[1].Type = "Item"
|
dest.Data[1].Type = "Item"
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -10,17 +10,20 @@ type Folder struct {
|
|||||||
Folders []*Folder `json:"folders,omitempty"`
|
Folders []*Folder `json:"folders,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Folder) ToDB(dest *db.Folder) bool {
|
func (f *Folder) ToDB(dest **db.Folder) bool {
|
||||||
if dest == nil {
|
if dest == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
dest.Name = f.Name
|
folder := &db.Folder{
|
||||||
dest.Sorting = f.Sorting
|
Name: f.Name,
|
||||||
dest.Color = f.Color
|
Sorting: f.Sorting,
|
||||||
copy(dest.Packs, f.Packs)
|
Color: f.Color,
|
||||||
|
}
|
||||||
|
copy(folder.Packs, f.Packs)
|
||||||
|
CopySliceToDB(&folder.Folders, f.Folders)
|
||||||
|
|
||||||
CopySliceToDB(&dest.Folders, f.Folders)
|
*dest = folder
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,20 +14,24 @@ type Grid struct {
|
|||||||
Thickness int `json:"thickness,omitempty"`
|
Thickness int `json:"thickness,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Grid) ToDB(dest *db.Grid) bool {
|
func (g *Grid) ToDB(dest **db.Grid) bool {
|
||||||
if dest == nil {
|
if dest == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
dest.Type = g.Type
|
grid := &db.Grid{
|
||||||
dest.Size = g.Size
|
Type: g.Type,
|
||||||
dest.Color = g.Color
|
Size: g.Size,
|
||||||
dest.Alpha = g.Alpha
|
Color: g.Color,
|
||||||
dest.Distance = g.Distance
|
Alpha: g.Alpha,
|
||||||
dest.Units = g.Units
|
Distance: g.Distance,
|
||||||
dest.Diagonals = g.Diagonals
|
Units: g.Units,
|
||||||
dest.Style = g.Style
|
Diagonals: g.Diagonals,
|
||||||
dest.Thickness = g.Thickness
|
Style: g.Style,
|
||||||
|
Thickness: g.Thickness,
|
||||||
|
}
|
||||||
|
|
||||||
|
*dest = grid
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,16 +10,20 @@ type Index struct {
|
|||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *Index) ToDB(dest *db.Index) bool {
|
func (i *Index) ToDB(dest **db.Index) bool {
|
||||||
if dest == nil {
|
if dest == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
dest.ID = i.Id
|
index := &db.Index{
|
||||||
dest.Folder = i.Folder
|
ID: i.Id,
|
||||||
dest.Img = i.Img
|
Folder: i.Folder,
|
||||||
dest.Name = i.Name
|
Img: i.Img,
|
||||||
dest.Type = i.Type
|
Name: i.Name,
|
||||||
|
Type: i.Type,
|
||||||
|
}
|
||||||
|
|
||||||
|
*dest = index
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,14 +9,18 @@ type Language struct {
|
|||||||
// SystemLanguagesFlags SystemLanguagesFlags `json:"flags"`
|
// SystemLanguagesFlags SystemLanguagesFlags `json:"flags"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *Language) ToDB(dest *db.Language) bool {
|
func (l *Language) ToDB(dest **db.Language) bool {
|
||||||
if dest == nil {
|
if dest == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
dest.Lang = l.Lang
|
lang := &db.Language{
|
||||||
dest.Name = l.Name
|
Lang: l.Lang,
|
||||||
dest.Path = l.Path
|
Name: l.Name,
|
||||||
|
Path: l.Path,
|
||||||
|
}
|
||||||
|
|
||||||
|
*dest = lang
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@@ -27,15 +31,19 @@ type SetupLanguage struct {
|
|||||||
Modules []*SetupLanguageModule `json:"modules"`
|
Modules []*SetupLanguageModule `json:"modules"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SetupLanguage) ToDB(dest *db.SetupLanguage) bool {
|
func (s *SetupLanguage) ToDB(dest **db.SetupLanguage) bool {
|
||||||
if dest == nil {
|
if dest == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
dest.ID = s.ID
|
lang := &db.SetupLanguage{
|
||||||
dest.Label = s.Label
|
ID: s.ID,
|
||||||
|
Label: s.Label,
|
||||||
|
}
|
||||||
|
|
||||||
CopySliceToDB(&dest.Modules, s.Modules)
|
CopySliceToDB(&lang.Modules, s.Modules)
|
||||||
|
|
||||||
|
*dest = lang
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,14 +8,18 @@ type Media struct {
|
|||||||
Caption string `json:"caption"`
|
Caption string `json:"caption"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Media) ToDB(dest *db.Media) bool {
|
func (m *Media) ToDB(dest **db.Media) bool {
|
||||||
if dest == nil {
|
if dest == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
dest.Type = m.Type
|
media := &db.Media{
|
||||||
dest.URL = m.URL
|
Type: m.Type,
|
||||||
dest.Caption = m.Caption
|
URL: m.URL,
|
||||||
|
Caption: m.Caption,
|
||||||
|
}
|
||||||
|
|
||||||
|
*dest = media
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,45 +32,49 @@ type SetupOptions struct {
|
|||||||
HotReload bool `json:"hotReload"`
|
HotReload bool `json:"hotReload"`
|
||||||
Language string `json:"language"`
|
Language string `json:"language"`
|
||||||
LocalHostname string `json:"localHostname"`
|
LocalHostname string `json:"localHostname"`
|
||||||
// PasswordSalt any `json:"passwordSalt"`
|
|
||||||
Port int `json:"port"`
|
Port int `json:"port"`
|
||||||
// Protocol any `json:"protocol"`
|
|
||||||
// ProxyPort any `json:"proxyPort"`
|
|
||||||
ProxySSL bool `json:"proxySSL"`
|
ProxySSL bool `json:"proxySSL"`
|
||||||
// RoutePrefix any `json:"routePrefix"`
|
|
||||||
// SslCert any `json:"sslCert"`
|
|
||||||
// SslKey any `json:"sslKey"`
|
|
||||||
Telemetry bool `json:"telemetry"`
|
Telemetry bool `json:"telemetry"`
|
||||||
UpdateChannel string `json:"updateChannel"`
|
UpdateChannel string `json:"updateChannel"`
|
||||||
Upnp bool `json:"upnp"`
|
Upnp bool `json:"upnp"`
|
||||||
|
DeleteNEDB bool `json:"deleteNEDB"`
|
||||||
|
NoBackups bool `json:"noBackups"`
|
||||||
|
// PasswordSalt any `json:"passwordSalt"`
|
||||||
|
// Protocol any `json:"protocol"`
|
||||||
|
// ProxyPort any `json:"proxyPort"`
|
||||||
|
// RoutePrefix any `json:"routePrefix"`
|
||||||
|
// SslCert any `json:"sslCert"`
|
||||||
|
// SslKey any `json:"sslKey"`
|
||||||
// UpnpLeaseDuration any `json:"upnpLeaseDuration"`
|
// UpnpLeaseDuration any `json:"upnpLeaseDuration"`
|
||||||
// World any `json:"world"`
|
// World any `json:"world"`
|
||||||
DeleteNEDB bool `json:"deleteNEDB"`
|
|
||||||
// AdminPassword string `json:"adminPassword"`
|
// AdminPassword string `json:"adminPassword"`
|
||||||
NoBackups bool `json:"noBackups"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SetupOptions) ToDB(dest *db.SetupOptions) bool {
|
func (s *SetupOptions) ToDB(dest **db.SetupOptions) bool {
|
||||||
if dest == nil {
|
if dest == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
dest.CompressSocket = s.CompressSocket
|
options := &db.SetupOptions{
|
||||||
dest.CompressStatic = s.CompressStatic
|
CompressSocket: s.CompressSocket,
|
||||||
dest.CSSTheme = s.CSSTheme
|
CompressStatic: s.CompressStatic,
|
||||||
dest.DataPath = s.DataPath
|
CSSTheme: s.CSSTheme,
|
||||||
dest.Fullscreen = s.Fullscreen
|
DataPath: s.DataPath,
|
||||||
dest.Hostname = s.Hostname
|
Fullscreen: s.Fullscreen,
|
||||||
dest.HotReload = s.HotReload
|
Hostname: s.Hostname,
|
||||||
dest.Language = s.Language
|
HotReload: s.HotReload,
|
||||||
dest.LocalHostname = s.LocalHostname
|
Language: s.Language,
|
||||||
dest.Port = s.Port
|
LocalHostname: s.LocalHostname,
|
||||||
dest.ProxySSL = s.ProxySSL
|
Port: s.Port,
|
||||||
dest.Telemetry = s.Telemetry
|
ProxySSL: s.ProxySSL,
|
||||||
dest.UpdateChannel = s.UpdateChannel
|
Telemetry: s.Telemetry,
|
||||||
dest.Upnp = s.Upnp
|
UpdateChannel: s.UpdateChannel,
|
||||||
dest.DeleteNEDB = s.DeleteNEDB
|
Upnp: s.Upnp,
|
||||||
dest.NoBackups = s.NoBackups
|
DeleteNEDB: s.DeleteNEDB,
|
||||||
|
NoBackups: s.NoBackups,
|
||||||
|
}
|
||||||
|
|
||||||
|
*dest = options
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,27 +22,32 @@ type Pack struct {
|
|||||||
// SystemPacksFlags SystemPacksFlags `json:"flags"`
|
// SystemPacksFlags SystemPacksFlags `json:"flags"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Pack) ToDB(dest *db.Pack) bool {
|
func (p *Pack) ToDB(dest **db.Pack) bool {
|
||||||
if dest == nil {
|
if dest == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
dest.Name = p.Name
|
pack := &db.Pack{
|
||||||
dest.Label = p.Label
|
Name: p.Name,
|
||||||
dest.Banner = p.Banner
|
Label: p.Label,
|
||||||
dest.Path = p.Path
|
Banner: p.Banner,
|
||||||
dest.Type = p.Type
|
Path: p.Path,
|
||||||
dest.System = p.System
|
Type: p.Type,
|
||||||
p.Ownership.ToDB(&dest.Ownership)
|
System: p.System,
|
||||||
dest.PackageType = p.PackageType
|
PackageType: p.PackageType,
|
||||||
dest.PackageName = p.PackageName
|
PackageName: p.PackageName,
|
||||||
dest.ID = p.Id
|
ID: p.Id,
|
||||||
|
}
|
||||||
|
|
||||||
|
p.Ownership.ToDB(&pack.Ownership)
|
||||||
|
|
||||||
wg := sync.WaitGroup{}
|
wg := sync.WaitGroup{}
|
||||||
go CopySliceToDBParallel(&wg, &dest.Index, p.Index)
|
go CopySliceToDBParallel(&wg, &pack.Index, p.Index)
|
||||||
go CopySliceToDBParallel(&wg, &dest.Folders, p.Folders)
|
go CopySliceToDBParallel(&wg, &pack.Folders, p.Folders)
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
|
||||||
|
*dest = pack
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,17 +63,21 @@ type PackFolder struct {
|
|||||||
// Packs0FoldersFlags any `json:"flags"`
|
// Packs0FoldersFlags any `json:"flags"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PackFolder) ToDB(dest *db.PackFolder) bool {
|
func (p *PackFolder) ToDB(dest **db.PackFolder) bool {
|
||||||
if dest == nil {
|
if dest == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
dest.ID = p.ID
|
packFolder := &db.PackFolder{
|
||||||
dest.Description = p.Description
|
ID: p.ID,
|
||||||
dest.Name = p.Name
|
Description: p.Description,
|
||||||
dest.Sort = p.Sort
|
Name: p.Name,
|
||||||
dest.Sorting = p.Sorting
|
Sort: p.Sort,
|
||||||
dest.Type = p.Type
|
Sorting: p.Sorting,
|
||||||
|
Type: p.Type,
|
||||||
|
}
|
||||||
|
|
||||||
|
*dest = packFolder
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,15 +76,19 @@ type News struct {
|
|||||||
Image string `json:"image"`
|
Image string `json:"image"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *News) ToDB(dest *db.News) bool {
|
func (n *News) ToDB(dest **db.News) bool {
|
||||||
if dest == nil {
|
if dest == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
dest.Title = n.Title
|
news := &db.News{
|
||||||
dest.Caption = n.Caption
|
Title: n.Title,
|
||||||
dest.URL = n.Caption
|
Caption: n.Caption,
|
||||||
dest.Image = n.Image
|
URL: n.Caption,
|
||||||
|
Image: n.Image,
|
||||||
|
}
|
||||||
|
|
||||||
|
*dest = news
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,12 +6,16 @@ type Style struct {
|
|||||||
Src string `json:"src"`
|
Src string `json:"src"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Style) ToDB(dest *db.Style) bool {
|
func (s *Style) ToDB(dest **db.Style) bool {
|
||||||
if dest == nil {
|
if dest == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
dest.Src = s.Src
|
style := &db.Style{
|
||||||
|
Src: s.Src,
|
||||||
|
}
|
||||||
|
|
||||||
|
*dest = style
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ func PackageWarningsToDB(dest *[]*db.PackageWarning, src map[string]PackageWarni
|
|||||||
i := 0
|
i := 0
|
||||||
for k, v := range src {
|
for k, v := range src {
|
||||||
(*dest)[i].Key = k
|
(*dest)[i].Key = k
|
||||||
v.ToDB(&(*dest)[i].Value)
|
v.ToDB((*dest)[i].Value)
|
||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user