CREATE TABLE IF NOT EXISTS modules (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    text_id VARCHAR(256) NOT NULL,
    title VARCHAR(256) NOT NULL,
    description TEXT NOT NULL,
    url VARCHAR(256) NOT NULL, 
    version VARCHAR(64) NOT NULL,
    availability INTEGER NOT NULL,

    created_at DATETIME NOT NULL DEFAULT current_timestamp
);

CREATE TABLE IF NOT EXISTS modules_compatibility (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    model_id INTEGER UNIQUE,
    minimum VARCHAR(64) NOT NULL,
    verified VARCHAR(64) NOT NULL,
    maximum VARCHAR(64) NOT NULL,

    FOREIGN KEY (model_id) REFERENCES modules(id) ON DELETE CASCADE
);

CREATE TABLE IF NOT EXISTS modules_languages (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    model_id INTEGER,
    language VARCHAR(256) NOT NULL,
    name VARCHAR(256) NOT NULL, 
    path VARCHAR(256) NOT NULL, 

    FOREIGN KEY (model_id) REFERENCES modules(id) ON DELETE CASCADE
);