<?php
require('constants.php');
$db = new SQLite3($DB_FILE);

// Create table if not exists
// Ensure the table creation includes group_id for new entries
$db->exec("CREATE TABLE IF NOT EXISTS entries (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    position TEXT NOT NULL,
    beschreibung TEXT,
    einheit TEXT,
    menge REAL,
    preis_pro_einheit REAL,
    gesamtpreis REAL,
    group_id INTEGER NOT NULL
)");

// Create 'groups' table if it doesn't exist
$db->exec("CREATE TABLE IF NOT EXISTS groups (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    name TEXT NOT NULL
)");
?>
