create_groups_table.php 772 B

12345678910111213141516171819202122
  1. <?php
  2. try {
  3. // Create the table using the existing database connection
  4. $pdo = new PDO('mysql:host=localhost;dbname=inventory_db', 'root', '');
  5. $sql = "CREATE TABLE IF NOT EXISTS accounting_category_group_names (
  6. id INT AUTO_INCREMENT PRIMARY KEY,
  7. category_group_code VARCHAR(3) NOT NULL,
  8. category_group_name VARCHAR(200) NOT NULL,
  9. description TEXT NULL,
  10. created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  11. updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  12. UNIQUE KEY unique_category_group_code (category_group_code)
  13. )";
  14. $pdo->exec($sql);
  15. echo "Table created successfully!\n";
  16. } catch (PDOException $e) {
  17. echo "Error: " . $e->getMessage() . "\n";
  18. }
  19. ?>