Added: Habit creation logic

This commit is contained in:
2024-12-26 18:47:00 +01:00
parent 85209ff134
commit 43960ddcb9
7 changed files with 158 additions and 2 deletions

View File

@ -85,7 +85,22 @@ class Database {
die("Failed to create progress table: " . $this->connection->error);
}
// Add more table creation logic as needed
// Create habits table
$habitsTableQuery = "CREATE TABLE IF NOT EXISTS habits (
id INT AUTO_INCREMENT PRIMARY KEY,
user_id INT NOT NULL,
title VARCHAR(100) NOT NULL,
frequency ENUM('Daily', 'Weekly', 'Custom') NOT NULL,
custom_frequency VARCHAR(255) DEFAULT NULL, -- Store crontab-like string
reward_points INT DEFAULT 1,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
) ENGINE=InnoDB;";
if (!$this->connection->query($habitsTableQuery)) {
die("Failed to create habits table: " . $this->connection->error);
}
}
/**