initial code commit
This commit is contained in:
44
src/Database/DatabaseSetup.php
Normal file
44
src/Database/DatabaseSetup.php
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user