<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "go_production_db";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
  die("Connection failed: " . $conn->connect_error);
}

// sql to create table
$sql = "CREATE TABLE IF NOT EXISTS homepage_layout (
    id INT AUTO_INCREMENT PRIMARY KEY,
    project_id INT NOT NULL,
    x_pos DECIMAL(5,2) DEFAULT 0,
    y_pos DECIMAL(5,2) DEFAULT 0,
    width DECIMAL(5,2) DEFAULT 20,
    height DECIMAL(5,2) DEFAULT 0,
    z_index INT DEFAULT 1,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE
)";

if ($conn->query($sql) === TRUE) {
  echo "Table homepage_layout created successfully";
} else {
  echo "Error creating table: " . $conn->error;
}

$conn->close();
?>
