initial code commit

This commit is contained in:
2024-02-09 20:52:11 -06:00
parent f5d267ea98
commit 532df6b9be
18 changed files with 583 additions and 1 deletions

View File

@@ -0,0 +1,44 @@
<?php
namespace Hpz937\BillReminder\Database;
class DatabaseSetup {
private DatabaseInterface $db;
public function __construct(DatabaseInterface $db) {
$this->db = $db;
}
public function setup(): void {
$this->createBillsTable();
$this->createUsersTable();
}
private function createBillsTable(): void {
$sql = <<<SQL
CREATE TABLE IF NOT EXISTS bills (
id INTEGER PRIMARY KEY AUTOINCREMENT,
dueDate TEXT NOT NULL,
amount REAL NOT NULL,
description TEXT,
isPaid INTEGER NOT NULL
);
SQL;
$this->db->query($sql);
}
private function createUsersTable(): void {
$sql = <<<SQL
CREATE TABLE users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
username TEXT UNIQUE NOT NULL,
passwordHash TEXT NOT NULL
);
SQL;
$this->db->query($sql);
}
// Additional methods to setup other tables as needed
}