CREATE IF NOT EXISTS TABLE users (
    id INT(69) PRIMARY KEY AUTO_INCREMENT,
    username VARCHAR(255) NOT NULL UNIQUE,
    email VARCHAR(255) NOT NULL,
    password VARCHAR(255) NOT NULL,
    created_at TIMESTAMP NOT NULL DEFAULT NOW(),
    updated_at TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW()
);

CREATE IF NOT EXISTS TABLE posts (
    id INT(69) PRIMARY KEY AUTO_INCREMENT,
    file_name VARCHAR(255) NOT NULL UNIQUE,
    author_id INT(69) NOT NULL,
    description TEXT NOT NULL,
    alt TEXT NOT NULL,
    created_at TIMESTAMP NOT NULL DEFAULT NOW(),
    updated_at TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW()
);

CREATE IF NOT EXISTS TABLE groups (
    id INT(69) PRIMARY KEY AUTO_INCREMENT,
    author_id INT(69) NOT NULL,
    name VARCHAR(255) NOT NULL,
    created_at TIMESTAMP NOT NULL DEFAULT NOW(),
    updated_at TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW()
);

CREATE IF NOT EXISTS TABLE permissions (
    id INT(69) PRIMARY KEY AUTO_INCREMENT,
    user_id INT(69) NOT NULL,
    admin BOOLEAN NOT NULL DEFAULT FALSE,
    create_posts BOOLEAN NOT NULL DEFAULT TRUE,
    updated_at TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW()
);

CREATE IF NOT EXISTS TABLE logs (
    id INT(69) PRIMARY KEY AUTO_INCREMENT,
    ip VARCHAR(255) NOT NULL,
    user_id INT(69) DEFAULT NULL,
    code INT(69) NOT NULL,
    note TEXT DEFAULT NULL,
    created_at TIMESTAMP NOT NULL DEFAULT NOW()
);

CREATE IF NOT EXISTS TABLE bans (
    id INT(69) PRIMARY KEY AUTO_INCREMENT,
    ip VARCHAR(255) NOT NULL,
    code INT(69) NOT NULL,
    note TEXT DEFAULT NULL,
    created_at TIMESTAMP NOT NULL DEFAULT NOW()
);